mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
Make session cleanup best effort
This commit is contained in:
1 parent
d1b3e2ad81
commit
f914290198
1 file changed
+16
-5
@@ -742,12 +742,23 @@ Http::shutdown()
|
||||
return;
|
||||
}
|
||||
|
||||
for ($i = 0; $i < ($count - $sessionLimit); $i++) {
|
||||
$session = array_shift($sessions);
|
||||
$dbForProject->deleteDocument('sessions', $session->getId());
|
||||
}
|
||||
try {
|
||||
for ($i = 0; $i < ($count - $sessionLimit); $i++) {
|
||||
$session = array_shift($sessions);
|
||||
|
||||
$dbForProject->purgeCachedDocument('users', $userId);
|
||||
if (!$session instanceof Document) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$dbForProject->deleteDocument('sessions', $session->getId());
|
||||
}
|
||||
} catch (\Throwable) {
|
||||
// Session-limit cleanup is best-effort. Concurrent session creation can race with
|
||||
// older-session deletion, but that should not fail the request that just created a
|
||||
// valid session for the user.
|
||||
} finally {
|
||||
$dbForProject->purgeCachedDocument('users', $userId);
|
||||
}
|
||||
});
|
||||
|
||||
Http::shutdown()
|
||||
|
||||
Reference in new issue
Block a user