Closed GeoffreyHuck closed 4 months ago
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 100.00%. Comparing base (
7694762
) to head (21b116c
). Report is 16 commits behind head on master.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
We first retrieve the list of sessions along with the most recent
issued_at
access token, sorted byissued_at DESC
. Then we delete the oldest.
I suppose/hope you do sorted by issued_at ASC
and take the first one instead :-D
I think for being future-safe (and conceptually correct), you must consider that a session might have no token at all, in which case either issued_at = 1000-01-01
or the session is always destroyed.
Related to #1022
Limits the number of sessions to 10 for a user.
When a new session is created (user logs in), we count the number of sessions. If it's more than 10, we remove the oldest one(s).
We first retrieve the list of sessions along with the most recent
issued_at
access token, sorted byissued_at DESC
. Then we delete the oldest.Adds to new Gherkin features:
there are X sessions for user @Session
, checks the number of sessions for a userthere is no session @Session
, checks that a session doesn't exists (has been deleted)Do we need an index?
The query is executed every time a user logs in.
Here's an explain of the request :
sessions
is filtered byuser_id
, which is a foreign key.access_tokens
needs to sort the matchingsession_id
byissued_at
. We will never have many access tokens for one session in the database because:So, no index required.
An unnecessary global variable was removed in the test package
Some lint tests were failing, which shown that we had a global variable
db
for the database in the test package. A refactoring was done to remove the global variable. Details are in the last commit message.