mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-14 11:20:53 +08:00
fix: resolve PHPStan static analysis warnings
This commit is contained in:
@@ -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
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user