update: session manage

This commit is contained in:
v2board
2022-12-18 16:06:51 +08:00
parent 2e251872b7
commit 044e8f6c30
3 changed files with 26 additions and 1 deletions

View File

@ -76,10 +76,23 @@ class AuthService
$cacheKey,
$sessions
)) return false;
return true;
}
public function getSessions()
{
return (array)Cache::get(CacheKey::get("USER_SESSIONS", $this->user->id), []);
}
public function delSession($sessionId)
{
$cacheKey = CacheKey::get("USER_SESSIONS", $this->user->id);
$sessions = (array)Cache::get($cacheKey, []);
unset($sessions[$sessionId]);
if (!Cache::put(
$cacheKey,
$sessions
)) return false;
return true;
}
}