develop
Last change
on this file since 9b4689a was 1c25bcf, checked in by Berat Kjufliju <kufliju@…>, 3 years ago |
added 2fa, bug fixes, edited blades
|
-
Property mode
set to
100644
|
File size:
712 bytes
|
Line | |
---|
1 | <?php
|
---|
2 |
|
---|
3 | namespace App\Http\Middleware;
|
---|
4 |
|
---|
5 | use App\Models\User;
|
---|
6 | use App\Services\Hashid;
|
---|
7 | use Closure;
|
---|
8 |
|
---|
9 | class CheckVerifyToken
|
---|
10 | {
|
---|
11 | /**
|
---|
12 | * Handle an incoming request.
|
---|
13 | *
|
---|
14 | * @param \Illuminate\Http\Request $request
|
---|
15 | * @param \Closure $next
|
---|
16 | * @return mixed
|
---|
17 | */
|
---|
18 | public function handle($request, Closure $next)
|
---|
19 | {
|
---|
20 | $hashId = new Hashid();
|
---|
21 | $id = $request->route("id");
|
---|
22 | $token = $request->route("token");
|
---|
23 | $user = User::findOrFail($hashId->decode($id));
|
---|
24 |
|
---|
25 | if ($user->verify_token !== $token || now()->greaterThan($user->updated_at->addMinutes(1))) {
|
---|
26 | return redirect()->route("auth.login");
|
---|
27 | }
|
---|
28 |
|
---|
29 | return $next($request);
|
---|
30 | }
|
---|
31 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.