Last active
March 17, 2021 06:02
-
-
Save tobyokeke/c5aac34ac81ca7c999e2a12fa7f3296e to your computer and use it in GitHub Desktop.
Laravel Multi-Auth
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Route::group(['prefix' => 'v1'],function(){ | |
//general unauthenticated routes here | |
Route::group(['prefix' => 'customer'],function(){ | |
Route::post('sign-up','CustomerController@signUp'); | |
//unauthenticated routes for customers here | |
Route::group( ['middleware' => ['auth:customer','scope:customer'] ],function(){ | |
// authenticated customer routes here | |
Route::post('dashboard','CustomerController@dashboard'); | |
}); | |
}); | |
Route::group(['prefix' => 'staff'],function(){ | |
Route::post('sign-up','StaffController@signUp'); | |
//unauthenticated routes for customers here | |
Route::group( ['middleware' => ['auth:staff','scope:staff'] ],function(){ | |
// authenticated staff routes here | |
Route::post('dashboard','StaffController@dashboard'); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In below code,
scope:customer
must bescopes:customer
if you have added middleware asscopes
in Kernel.phpRoute::group( ['middleware' => ['auth:customer','scope:customer'] ],function(){ // authenticated customer routes here Route::post('dashboard','CustomerController@dashboard'); }); });
I have tested on Laravel 8, it worked perfectly. Thanks for sharing required tutorial.