source: app/Http/Middleware/CheckCreatePassword.php@ 0924b6c

Last change on this file since 0924b6c was 0924b6c, checked in by Özkan İliyaz <iliyaz_96@…>, 4 years ago

initial commit

  • Property mode set to 100644
File size: 923 bytes
Line 
1<?php
2
3namespace App\Http\Middleware;
4
5use Closure;
6use App\Models\User;
7use Illuminate\Support\Carbon;
8
9class CheckCreatePassword
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 $id = $request->route("id");
21 $token = $request->route("token");
22
23 $user = User::findOrFail($id);
24
25 if($user->is_active) {
26 return redirect()->route("auth.loginShow");
27 }
28
29 if($user->verify_token != $token) {
30 return redirect()->route("blog.index");
31 }
32
33 if(!$user->is_forgot_password) {
34 if(Carbon::now()->greaterThan($user->created_at->addMinutes(10))) {
35 return redirect()->route("auth.loginShow");
36 }
37 }
38
39 return $next($request);
40 }
41}
Note: See TracBrowser for help on using the repository browser.