-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Created
AdminAuthenticate
middleware & register in Kernel
* If the user is not authenticated then redirects back to the admin login form. So we created `AdminAuthenticate` middleware which helps to protect our dashboard * We register this Middleware class `AdminAuthenticate` in Kernel with the short name `auth.admin` so we can consume this one easily on our routes.
- Loading branch information
ahmadhuss
committed
May 10, 2021
1 parent
2059362
commit 6995e72
Showing
2 changed files
with
22 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace App\Http\Middleware; | ||
|
||
use Illuminate\Auth\Middleware\Authenticate as Middleware; | ||
|
||
class AdminAuthenticate extends Middleware | ||
{ | ||
/** | ||
* Get the path the admin should be redirected to when they are not authenticated. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @return string|null | ||
*/ | ||
protected function redirectTo($request) | ||
{ | ||
if (! $request->expectsJson()) { | ||
return route('admin.login'); | ||
} | ||
} | ||
} |