mirror of
https://gitee.com/zongzhige/shopxo.git
synced 2024-12-04 13:00:05 +08:00
用户登录信息获取优化
This commit is contained in:
parent
0754f42ef0
commit
95e5c67d97
@ -37,34 +37,37 @@ class UserService
|
|||||||
* @desc description
|
* @desc description
|
||||||
*/
|
*/
|
||||||
public static function LoginUserInfo()
|
public static function LoginUserInfo()
|
||||||
|
{
|
||||||
|
// 静态数据避免重复读取
|
||||||
|
static $user_login_info = null;
|
||||||
|
if($user_login_info === null)
|
||||||
{
|
{
|
||||||
// 参数
|
// 参数
|
||||||
$params = input();
|
$params = input();
|
||||||
|
|
||||||
// 用户数据处理
|
// 用户数据处理
|
||||||
$user = null;
|
|
||||||
if(APPLICATION == 'web')
|
if(APPLICATION == 'web')
|
||||||
{
|
{
|
||||||
// web用户session
|
// web用户session
|
||||||
$user = MySession(self::$user_login_key);
|
$user_login_info = MySession(self::$user_login_key);
|
||||||
|
|
||||||
// 用户信息为空,指定了token则设置登录信息
|
// 用户信息为空,指定了token则设置登录信息
|
||||||
if(empty($user) && !empty($params['token']))
|
if(empty($user_login_info) && !empty($params['token']))
|
||||||
{
|
{
|
||||||
$user = self::UserTokenData($params['token']);
|
$user_login_info = self::UserTokenData($params['token']);
|
||||||
if($user !== null && isset($user['id']))
|
if($user_login_info !== null && isset($user_login_info['id']))
|
||||||
{
|
{
|
||||||
self::UserLoginRecord($user['id']);
|
self::UserLoginRecord($user_login_info['id']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(!empty($params['token']))
|
if(!empty($params['token']))
|
||||||
{
|
{
|
||||||
$user = self::UserTokenData($params['token']);
|
$user_login_info = self::UserTokenData($params['token']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return $user;
|
return $user_login_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user