This commit is contained in:
2026-03-25 02:48:30 +08:00
parent 8704434c36
commit 66bcd8061a
23 changed files with 1204 additions and 208 deletions
+24 -12
View File
@@ -21,12 +21,10 @@ class Jwt
protected static $config = [];
protected static $options = [];
protected static $disallowFields = [
'password','trade_password','totp_secret',//安全信息
'created_at','updated_at','loginfailure',//系统信息
//'last_time','last_ip','join_time','join_ip',最近登录信息
//'score',
'level',
'trade_password','password','empty_password',
'client','loginfailure',
'currency1','currency2','currency3','currency4','currency5','currency6','currency7','currency8','currency9',
'token','prev_time','loginfailure','successions','maxsuccessions',
];
/**
* 注册用户
@@ -296,7 +294,7 @@ class Jwt
];
$_token = \support\Jwt\JwtToken::generateToken($_user);
$user->token = $_token['access_token'];
return self::getUserinfo($user);
return self::getUserinfo($user,true);
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
@@ -356,13 +354,27 @@ class Jwt
/**
* 获取会员基本信息
*/
public static function getUserinfo($user=null)
public static function getUserinfo($user=null,$withToken = false)
{
$data = self::getUser($user)->toArray();
$data = self::getUser($user);
if(!is_array($data)){
$data = $data->toArray();
}
$data['has_trade_password'] = $data['trade_password'] ? true: false;
$data['has_empty_password'] = $data['empty_password'] ? true: false;
$role_arr = [
'1' => __('普通用户'),
'2' => __('VIP'),
'3' => __('SVIP1'),
'4' => __('SVIP2'),
];
$data['role'] = isset($role_arr[$data['role_id']]) ? $role_arr[$data['role_id']] : __('普通用户');
$disallowFields = self::getDisallowFields();
$userinfo = array_diff_key($data, array_flip($disallowFields));
$userinfo['has_trade_password'] = $data['trade_password'] ? true: false;
return $userinfo;
$data = array_diff_key($data, array_flip($disallowFields));
if($withToken){
$data['token'] = $user->token;
}
return $data;
}
/**