webman迁移-优化
This commit is contained in:
@@ -109,10 +109,16 @@ class Index extends Backend
|
||||
$res = $this->auth->login($username, $password, (bool) $keep);
|
||||
if ($res === true) {
|
||||
$userInfo = $this->auth->getInfo();
|
||||
// 兜底:若 getInfo 未返回 token,在控制器层生成并入库
|
||||
if (empty($userInfo['token']) && $this->auth->isLogin()) {
|
||||
$adminId = $this->auth->id;
|
||||
$keepTime = (int) config('buildadmin.admin_token_keep_time', 86400 * 3);
|
||||
// 兜底:若 getInfo 未返回 token,在控制器层生成并入库(login 成功时必有 adminId)
|
||||
if (empty($userInfo['token']) && $adminId) {
|
||||
$userInfo['token'] = Random::uuid();
|
||||
Token::set($userInfo['token'], \app\admin\library\Auth::TOKEN_TYPE, $this->auth->id, (int) config('buildadmin.admin_token_keep_time', 86400 * 3));
|
||||
Token::set($userInfo['token'], \app\admin\library\Auth::TOKEN_TYPE, $adminId, $keepTime);
|
||||
}
|
||||
if (empty($userInfo['refresh_token']) && $keep && $adminId) {
|
||||
$userInfo['refresh_token'] = Random::uuid();
|
||||
Token::set($userInfo['refresh_token'], \app\admin\library\Auth::TOKEN_TYPE . '-refresh', $adminId, 2592000);
|
||||
}
|
||||
return $this->success(__('Login succeeded!'), [
|
||||
'userInfo' => $userInfo
|
||||
|
||||
Reference in New Issue
Block a user