后台登录

This commit is contained in:
2026-01-15 05:26:34 +08:00
parent b367d1a97d
commit f24de31a92
2 changed files with 13 additions and 7 deletions

View File

@@ -229,6 +229,7 @@ class Auth extends \fast\Auth
if ($this->logined) {
return true;
}
$admin = Session::get('admin');
if (!$admin) {
$admin = Cache::get("admin_" . $token);
@@ -239,6 +240,7 @@ class Auth extends \fast\Auth
// Session::set("admin.safecode", $this->getEncryptSafecode($admin));
}
}
if (!$admin) {
return false;
}
@@ -246,6 +248,7 @@ class Auth extends \fast\Auth
if (!$my) {
return false;
}
//校验安全码,可用于判断关键信息发生了变更需要重新登录
// if (!isset($admin['safecode']) || $this->getEncryptSafecode($my) !== $admin['safecode']) {
// $this->logout();
@@ -259,12 +262,13 @@ class Auth extends \fast\Auth
}
}
//判断管理员IP是否变动
if (Config::get('fastadmin.loginip_check')) {
if (!isset($admin['loginip']) || $admin['loginip'] != request()->ip()) {
$this->logout();
return false;
}
}
// if (Config::get('fastadmin.loginip_check')) {
// if (!isset($admin['loginip']) || $admin['loginip'] != request()->ip()) {
// $this->logout();
// return false;
// }
//
// }
$this->logined = true;
return true;
}

View File

@@ -142,7 +142,9 @@ class adminApi extends Controller
//通过头部信息获取authorization0
$token = $this->request->server('HTTP_AUTHORIZATION', $this->request->request('token', \think\Cookie::get('token')));
//检测是否登录
if (!$this->auth->isLogin($token)) {
// if (!$this->auth->isLogin($token)) {
$auth = new Auth ;
if (!$auth->isLogin($token)) {
Hook::listen('admin_nologin', $this);
$url = Session::get('referer');
$url = $url ? $url : $this->request->url();