更新解析token

This commit is contained in:
yaooo 2023-11-24 10:53:34 +08:00
parent 9d422a2d45
commit 134765255d

View File

@ -228,8 +228,35 @@ class LoginLogic extends BaseLogic
$where = ['account|mobile' => $jwtData['phone']];
$user = User::where($where)->findOrEmpty();
if ($user->isEmpty()) {
self::setError('用户不存在,请联系管理员开通供销系统账户');
return false;
$user_id = $jwtData['uid'];
$find = Db::name('user_other')->where('other_user_id', $user_id)->where('type', 'shop_user')->find();
if ($find) {
$user = User::where('id', $find['user_id'])->findOrEmpty();
if ($user->isEmpty()) {
self::setError('用户不存在,请联系管理员开通供销系统账户');
return false;
}
$terminal=3;
$Android=IndexLogic::isAndroid();
if($Android){
$terminal=5;
}
$ios=IndexLogic::isIOS();
if($ios){
$terminal=6;
}
$userInfo = UserTokenService::setToken($user->id, $terminal);
//返回登录信息
$avatar = $user->avatar ?: Config::get('project.default_image.user_avatar');
$avatar = FileService::getFileUrl($avatar);
return [
'nickname' => $userInfo['nickname'],
'sn' => $userInfo['sn'],
'mobile' => $userInfo['mobile'],
'avatar' => $avatar,
'token' => $userInfo['token'],
];
}
}
//更新登录信息
$user->login_time = time();