source: app/Http/Middleware/CheckVerifyToken.php@ deff0bc

Last change on this file since deff0bc was 0a1fb54, checked in by beratkjufliju <kufliju@…>, 3 years ago

bug fixes

  • Property mode set to 100644
File size: 751 bytes
RevLine 
[1c25bcf]1<?php
2
3namespace App\Http\Middleware;
4
5use App\Models\User;
6use App\Services\Hashid;
7use Closure;
[0a1fb54]8use Illuminate\Support\Carbon;
[1c25bcf]9
10class 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.