2022-06-04 11:22:19 -04:00
|
|
|
<?php
|
|
|
|
declare (strict_types=1);
|
|
|
|
|
|
|
|
namespace app\middleware;
|
|
|
|
|
|
|
|
|
|
|
|
class AuthAdmin
|
|
|
|
{
|
|
|
|
public function handle($request, \Closure $next)
|
|
|
|
{
|
|
|
|
$islogin = false;
|
|
|
|
$cookie = cookie('admin_token');
|
|
|
|
if($cookie){
|
|
|
|
$token=authcode($cookie, 'DECODE', config_get('syskey'));
|
2022-08-15 06:39:40 -04:00
|
|
|
if($token){
|
|
|
|
list($user, $sid, $expiretime) = explode("\t", $token);
|
|
|
|
$session=md5(config_get('admin_username').config_get('admin_password'));
|
|
|
|
if($session==$sid && $expiretime>time()) {
|
|
|
|
$islogin = true;
|
|
|
|
}
|
2022-06-04 11:22:19 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
request()->islogin = $islogin;
|
|
|
|
return $next($request);
|
|
|
|
}
|
|
|
|
}
|