账号登录

This commit is contained in:
2026-03-10 14:25:17 +08:00
parent cb692a8f90
commit 6dbcaecf68
5 changed files with 60 additions and 26 deletions
+16 -24
View File
@@ -23,10 +23,10 @@ class AuthLogic
public function uPwdLogin(array $data): array
{
$user = $this->validateUser($data['account'], $data['password']);
$system = $this->validateSystem($data['system_code']);
$this->validateSystemPermission($user, $system);
//$system = $this->validateSystem($data['system_code']);
//$this->validateSystemPermission($user, $system);
return $this->generateTokensAndReturn($user, $system, $data);
return $this->generateTokensAndReturn($user, $data);
}
/**
@@ -37,14 +37,14 @@ class AuthLogic
{
$feishuUserInfo = $this->getFeishuUserInfo($data);
return $feishuUserInfo;
$user = $this->getOrCreateUser($feishuUserInfo);
$system = $this->validateSystem($data['system_code']);
if ($user->isLogin) {
$this->validateSystemPermission($user, $system);
}
return $this->generateTokensAndReturn($user, $system, $data);
// $user = $this->getOrCreateUser($feishuUserInfo);
//
// $system = $this->validateSystem($data['system_code']);
// if ($user->isLogin) {
// $this->validateSystemPermission($user, $system);
// }
//
// return $this->generateTokensAndReturn($user, $system, $data);
}
/**
@@ -168,24 +168,16 @@ class AuthLogic
/**
* 生成并记录token,返回包含token的响应数据
*/
private function generateTokensAndReturn(User $user, Systems $system, array $data): array
private function generateTokensAndReturn(User $user, array $data): array
{
$payload = $this->buildJwtPayload($user, $system);
$token = $this->generateAccessToken($payload);
$refreshToken = $this->generateRefreshToken($user->id, $data['system_code']);
$homeUrl = $this->getHome($system->id, $payload);
// $refreshToken = $this->generateRefreshToken($user->id, $data['system_code']);
// 记录 token 到 Redis 和 MySQL
$this->recordUserToken($user->id, $token, $data['system_code']);
return [
'access_token' => $token,
'refresh_token' => $refreshToken,
'expires_in' => config('jwt.jwt_expiration'),
'system_code' => $data['system_code'],
'corp_abbr' => $data['corp_abbr'],
'union_id' => $user->union_id,
'role' => $user->role,
'role_wp' => $user->role_wp,
'login_type' => $data['login_type'],
'home_url' => $homeUrl,
// 'payload' => $payload,
];
}