36 lines
944 B
PHP
36 lines
944 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Middleware;
|
||
|
|
|
||
|
|
use Closure;
|
||
|
|
use Illuminate\Support\Carbon;
|
||
|
|
use Illuminate\Support\Facades\Session;
|
||
|
|
|
||
|
|
class EmployeeOutDatedPassword
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* Handle an incoming request.
|
||
|
|
*
|
||
|
|
* @param \Illuminate\Http\Request $request
|
||
|
|
* @param \Closure $next
|
||
|
|
* @return mixed
|
||
|
|
*/
|
||
|
|
public function handle($request, Closure $next)
|
||
|
|
{
|
||
|
|
/** @var \App\Models\Employee */
|
||
|
|
$employee = auth('employee')->user();
|
||
|
|
if (
|
||
|
|
$employee->password_date->addMonths(3)->lt(Carbon::now()) and
|
||
|
|
!in_array($request->route()->getName(), [
|
||
|
|
'fo.employees.passwordChange', 'fo.employees.passwordChangeSubmit',
|
||
|
|
'fo.employees.logout'
|
||
|
|
])
|
||
|
|
) {
|
||
|
|
Session::put('required', true);
|
||
|
|
Session::save();
|
||
|
|
return redirect()->route('fo.employees.passwordChange');
|
||
|
|
}
|
||
|
|
return $next($request);
|
||
|
|
}
|
||
|
|
}
|