Skip to content

Commit

Permalink
Add auth guard to routes (#1603)
Browse files Browse the repository at this point in the history
  • Loading branch information
hafezdivandari authored Dec 2, 2022
1 parent 662325a commit 835febb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
13 changes: 13 additions & 0 deletions config/passport.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

return [

/*
|--------------------------------------------------------------------------
| Passport Guard
|--------------------------------------------------------------------------
|
| Here you may specify which authentication guard Passport will use when
| authenticating users. This value should correspond with one of your
| guards that is already present in your "auth" configuration file.
|
*/

'guard' => 'web',

/*
|--------------------------------------------------------------------------
| Encryption Keys
Expand Down
4 changes: 3 additions & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
'middleware' => 'web',
]);

Route::middleware(['web', 'auth'])->group(function () {
$guard = config('passport.guard', null);

Route::middleware(['web', $guard ? 'auth:'.$guard : 'auth'])->group(function () {
Route::post('/token/refresh', [
'uses' => 'TransientTokenController@refresh',
'as' => 'token.refresh',
Expand Down

0 comments on commit 835febb

Please sign in to comment.