Skip to content

Commit

Permalink
Add custom guards
Browse files Browse the repository at this point in the history
  • Loading branch information
arifszn committed Sep 16, 2022
1 parent c3f257c commit 5d0f438
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
18 changes: 14 additions & 4 deletions config/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@
'driver' => 'session',
'provider' => 'users',
],

'user' => [
'driver' => 'sanctum',
'provider' => 'users',
],

'admin' => [
'driver' => 'sanctum',
'provider' => 'admins',
],
],

/*
Expand All @@ -65,10 +75,10 @@
'model' => App\Models\User::class,
],

// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
'admins' => [
'driver' => 'eloquent',
'model' => App\Models\Admin::class,
],
],

/*
Expand Down
3 changes: 2 additions & 1 deletion routes/api/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@

Route::post('/signup', [AuthController::class, 'signup']);
Route::post('/login', [AuthController::class, 'login']);
Route::post('/logout', [AuthController::class, 'logout'])->middleware('auth:sanctum');
Route::post('/logout', [AuthController::class, 'logout'])->middleware('auth:user');

Route::group(['prefix' => 'admin'], function () {
Route::post('/login', [AuthController::class, 'adminLogin']);
Route::post('/logout', [AuthController::class, 'adminLogout'])->middleware('auth:admin');
});

0 comments on commit 5d0f438

Please sign in to comment.