-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathPasswordExpires.php
36 lines (31 loc) · 1.08 KB
/
PasswordExpires.php
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
28
29
30
31
32
33
34
35
36
<?php
namespace App\Domains\Auth\Http\Middleware;
use Carbon\Carbon;
use Closure;
/**
* Class PasswordExpires.
*/
class PasswordExpires
{
/**
* @param $request
* @param Closure $next
* @return \Illuminate\Http\RedirectResponse|mixed
*
* @throws \Exception
*/
public function handle($request, Closure $next)
{
if (is_numeric(config('boilerplate.access.user.password_expires_days'))) {
$password_changed_at = new Carbon($request->user()->password_changed_at ?? $request->user()->created_at);
if (now()->diffInDays($password_changed_at) >= config('boilerplate.access.user.password_expires_days')) {
return redirect()
->route('frontend.auth.password.expired')
->withFlashWarning(__('Your password has expired. We require you to change your password every :days days for security purposes.', [
'days' => config('boilerplate.access.user.password_expires_days'),
]));
}
}
return $next($request);
}
}