-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGuard.php
More file actions
27 lines (24 loc) · 690 Bytes
/
Copy pathGuard.php
File metadata and controls
27 lines (24 loc) · 690 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
/**
* Multi-guard authentication middleware.
*
* Usage (bootstrap/app.php):
* ->withMiddleware(function (Middleware $m) {
* $m->alias(['guard:user' => Guard::class, ...]);
* })
*
* Accepts a guard name argument: guard:user | guard:staff | guard:control
* Redirects unauthenticated requests to the appropriate login route.
*/
class Guard
{
public function handle(Request $request, Closure $next, string $guard): Response
{
// Check auth($guard)->check(), redirect to {$guard}.login if not authenticated
// ...
}
}