adenvt/laravel-coreui-vue

Route except.

Closed this issue · 4 comments

I want use the laravel auth support what the best praticies to do this ? I maked the follow code in routes/web.php:

Auth::routes();

Route::middleware('auth')->group(function () {
    Route::get('/api/teste' , function (){
        return 'ok';
    });
});
Route::get('/' , 'HomeController@index');
Route::prefix('/')->group(function ($route) {
    Route::get('{vue_capture_1?}/', 'AppController@index')
        ->middleware(['speed', 'auth'])
        ->where('vue_capture_1', '[\/\w\.\,\-]*');
});

This code make any route is captured to vue-router and make vue-router to handling everything (you can check resource/js/coreui/router/index.js).

Route::get('/{vue_capture?}', 'AppController@index')
    ->middleware(['speed'])
    ->where('vue_capture', '[\/\w\.\,\-]*');

define another route before that route (like your code) it ok.

but i not recommended to use default laravel auth, because its broke the SPA concept. Better to write own login logic as API to generate auth token (like JWT) and save it to localStorage, and make guard redirection if token not present via vue-router.

This is provisory authentication mode. Thanks for your feedback

I don't recomend use this for full in SPA Aplications but in some moment we don't need make a full Auth2 to make a simple aplication. The Laravel provides a fast athentication module.
Look this example:

Auth::routes();
Auth::routes(['register' => false]);

Route::get('/home', function () {
    return redirect('/');
});

Route::middleware('auth')->group(function () {
  // Here contains all resources proteteds by middleware auth
});

Route::get('/', 'PortalController@index');

Route::prefix('/painel')->group(function () {
    Route::get('{vue_capture?}/', 'PainelController@index')
        ->middleware(['speed', 'auth'])
        ->where('vue_capture', '[\/\w\.\,\-]*');
});

Sorry, I can accept your request.

Main purpose when I created this repo is actually for kickstart my internal project which always use custom authentication. I have no intention to change this behavior.

You can fork this repo and freely custom based your project requirement.