Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TAN-1768] Add user last_login_at column and functionality #7816

Conversation

jinjagit
Copy link
Contributor

@jinjagit jinjagit commented May 4, 2024

WIP (experimental)

Changelog

@jinjagit jinjagit self-assigned this May 4, 2024
@jinjagit jinjagit marked this pull request as draft May 4, 2024 21:06
Copy link

@jinjagit jinjagit marked this pull request as ready for review May 6, 2024 11:01
@jinjagit
Copy link
Contributor Author

jinjagit commented May 6, 2024

@alexander-cit I'm interested in your opinion on this experimental PR.

It seems the only unique event (that I have found) that can be used to reliably capture a login event is the encoding of a new JWT token. This seems to capture both email and SSO logins, and avoid false-positives.

Inserting the method to write to the User record into a branch of a conditional in the AuthToken#intialize method feels like the wrong way to implement this, however.

Is my approach the right one, or can you think of a better way to capture login date-times?

If it is correct, then can you think of a more elegant/conventional implementation?

@alexander-cit
Copy link
Contributor

alexander-cit commented May 6, 2024

feels like the wrong way to implement this, however.

It's a very good point. AuthToken should probably not have any side effects. E.g., if you want to generate it in the Rails console to be able to log in as some user.

Maybe you could add a method that creates a token and updates the user in AuthToken::Authenticable? Maybe you would not need to query the DB in this case and you could use current_user or something like that.

@jinjagit jinjagit marked this pull request as draft May 6, 2024 12:53
@jinjagit
Copy link
Contributor Author

Closed, in favor of #7846

@jinjagit jinjagit closed this May 19, 2024
@jinjagit jinjagit deleted the TAN-1768-add-user-last-login-at-column-and-functionality branch May 22, 2024 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants