登录优化

This commit is contained in:
Devil 2020-11-27 15:57:34 +08:00
parent 48ff51cc3d
commit 83b90f1cf4
4 changed files with 14 additions and 16 deletions

View File

@ -193,9 +193,7 @@ class Common extends Controller
} else {
die('<script type="text/javascript">if(self.frameElement && self.frameElement.tagName == "IFRAME"){parent.location.reload();}else{window.location.href="'.MyUrl('admin/admin/logininfo').'";}</script>');
}
} else {
AdminService::LoginRefresh($this->admin);
}
}
}
/**

View File

@ -382,12 +382,11 @@ class AdminService
return DataReturn('密码错误', -3);
}
// 校验成功
// session存储
session(self::$admin_login_key, $admin);
// 种session
self::LoginSession($admin);
// 返回数据,更新数据库
if(session(self::$admin_login_key) != null)
if(self::LoginInfo())
{
$login_salt = GetNumberCode(6);
$data = array(
@ -407,7 +406,7 @@ class AdminService
}
// 失败
session(self::$admin_login_key, null);
self::LoginLogout();
return DataReturn('登录失败,请稍后再试!', -100);
}
@ -425,7 +424,7 @@ class AdminService
}
/**
* 登录刷新
* 登录种session
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
@ -433,7 +432,7 @@ class AdminService
* @desc description
* @param [array] $admin [管理员登录信息]
*/
public static function LoginRefresh($admin)
public static function LoginSession($admin)
{
return session(self::$admin_login_key, $admin);
}

View File

@ -25,6 +25,9 @@ use app\service\ResourcesService;
*/
class UserService
{
// user登录session key
public static $user_login_key = 'user_login';
/**
* 获取用户登录信息
* @author Devil
@ -43,7 +46,7 @@ class UserService
if(APPLICATION == 'web')
{
// web用户session
$user = session('user');
$user = session(self::$user_login_key);
// token仅小程序浏览器环境和api接口环境中有效
if(empty($user) && !empty($params['token']) && in_array(MiniAppEnv(), config('shopxo.mini_app_type_list')))
@ -413,8 +416,8 @@ class UserService
if($is_app == false)
{
// 存储session
session('user', $user);
return (session('user') !== null);
session(self::$user_login_key, $user);
return (session(self::$user_login_key) !== null);
}
}
}
@ -1871,7 +1874,7 @@ class UserService
$user = self::LoginUserInfo();
// 清除session
session('user', null);
session(self::$user_login_key, null);
// html代码
$body_html = [];

View File

@ -39,8 +39,6 @@ if($common_session_is_use_cache == 1)
'prefix' => 'shopxo',
// 驱动方式 支持redis memcache memcached
'type' => '',
// 过期时间(默认3600秒)
'expire' => 3600,
// 是否自动开启 SESSION
'auto_start' => true,
];