后台登录
This commit is contained in:
@@ -229,6 +229,7 @@ class Auth extends \fast\Auth
|
|||||||
if ($this->logined) {
|
if ($this->logined) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$admin = Session::get('admin');
|
$admin = Session::get('admin');
|
||||||
if (!$admin) {
|
if (!$admin) {
|
||||||
$admin = Cache::get("admin_" . $token);
|
$admin = Cache::get("admin_" . $token);
|
||||||
@@ -239,6 +240,7 @@ class Auth extends \fast\Auth
|
|||||||
// Session::set("admin.safecode", $this->getEncryptSafecode($admin));
|
// Session::set("admin.safecode", $this->getEncryptSafecode($admin));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$admin) {
|
if (!$admin) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -246,6 +248,7 @@ class Auth extends \fast\Auth
|
|||||||
if (!$my) {
|
if (!$my) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//校验安全码,可用于判断关键信息发生了变更需要重新登录
|
//校验安全码,可用于判断关键信息发生了变更需要重新登录
|
||||||
// if (!isset($admin['safecode']) || $this->getEncryptSafecode($my) !== $admin['safecode']) {
|
// if (!isset($admin['safecode']) || $this->getEncryptSafecode($my) !== $admin['safecode']) {
|
||||||
// $this->logout();
|
// $this->logout();
|
||||||
@@ -259,12 +262,13 @@ class Auth extends \fast\Auth
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//判断管理员IP是否变动
|
//判断管理员IP是否变动
|
||||||
if (Config::get('fastadmin.loginip_check')) {
|
// if (Config::get('fastadmin.loginip_check')) {
|
||||||
if (!isset($admin['loginip']) || $admin['loginip'] != request()->ip()) {
|
// if (!isset($admin['loginip']) || $admin['loginip'] != request()->ip()) {
|
||||||
$this->logout();
|
// $this->logout();
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
}
|
//
|
||||||
|
// }
|
||||||
$this->logined = true;
|
$this->logined = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,7 +142,9 @@ class adminApi extends Controller
|
|||||||
//通过头部信息获取authorization0
|
//通过头部信息获取authorization0
|
||||||
$token = $this->request->server('HTTP_AUTHORIZATION', $this->request->request('token', \think\Cookie::get('token')));
|
$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);
|
Hook::listen('admin_nologin', $this);
|
||||||
$url = Session::get('referer');
|
$url = Session::get('referer');
|
||||||
$url = $url ? $url : $this->request->url();
|
$url = $url ? $url : $this->request->url();
|
||||||
|
|||||||
Reference in New Issue
Block a user