fix: resolve PHPStan static analysis warnings

This commit is contained in:
xboard
2025-04-14 02:12:42 +08:00
parent 3d254c02c1
commit 2d3e4b4a95
84 changed files with 2330 additions and 1190 deletions

View File

@@ -40,7 +40,13 @@ class AuthService
return $this->user->tokens()->get()->toArray();
}
public function removeSession(): bool
public function removeSession(string $sessionId): bool
{
$this->user->tokens()->where('id', $sessionId)->delete();
return true;
}
public function removeAllSessions(): bool
{
$this->user->tokens()->delete();
return true;
@@ -54,4 +60,26 @@ class AuthService
return $accessToken?->tokenable;
}
/**
* 解密认证数据
*
* @param string $authorization
* @return array|null 用户数据或null
*/
public static function decryptAuthData(string $authorization): ?array
{
$user = self::findUserByBearerToken($authorization);
if (!$user) {
return null;
}
return [
'id' => $user->id,
'email' => $user->email,
'is_admin' => (bool)$user->is_admin,
'is_staff' => (bool)$user->is_staff
];
}
}