2023-08-15 12:11:38 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
|
|
|
|
use Closure;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
|
|
|
|
class CheckForcePasswordReset
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Handle an incoming request.
|
|
|
|
*
|
|
|
|
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
|
|
|
*/
|
|
|
|
public function handle(Request $request, Closure $next): Response
|
|
|
|
{
|
|
|
|
if (auth()->user()) {
|
2023-09-06 10:07:34 +00:00
|
|
|
if ($request->path() === 'auth/link') {
|
|
|
|
auth()->logout();
|
|
|
|
request()->session()->invalidate();
|
|
|
|
request()->session()->regenerateToken();
|
|
|
|
return $next($request);
|
|
|
|
}
|
2023-08-15 12:11:38 +00:00
|
|
|
$force_password_reset = auth()->user()->force_password_reset;
|
|
|
|
if ($force_password_reset) {
|
2023-12-13 14:22:37 +00:00
|
|
|
if ($request->routeIs('auth.force-password-reset') || $request->path() === 'force-password-reset' || $request->path() === 'livewire/update' || $request->path() === 'logout') {
|
2023-08-15 12:11:38 +00:00
|
|
|
return $next($request);
|
|
|
|
}
|
|
|
|
return redirect()->route('auth.force-password-reset');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $next($request);
|
|
|
|
}
|
|
|
|
}
|