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