fix(session): Update last_seen when user session is validated
#50835
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
While doing some maintenance on my instance, I've saw a lot of users with last_seen timestamp a few months ago, like 7 months ago or even more than a year. So, I've disabled them.
A couple of minutes later, some of them were complaining their user account was disabled 😿
Example:
As you can see,
last_seenstates user was last seen (wrongly) 6 months ago.Yet, on the webserver log, we can see that this same user performed some operations only minutes ago:
Problem is that those users NEVER use the WebUI, they only use some apps to sync their data, like Calendar or Contacts sync, etc. So, they never complete a full logout + full login.
My proposal here is to update the
last_seentimestamp also when we validate their session, since that, in my opinion, as an instance administrator, I want to be able to rely on thelast_seenfield to really know when the user was last seen (and by last seen, I mean user has done some kind of legit activity on the instance, while being a valid user). As per actual logic, it would be updated, at most, once every 60s.IMO, this is actually a bug (not a feature) because updating
last_seenfield only on full logout + login is not reliable.Please review.
Checklist