https://supertokens.com/ logo
c

CaptainPhoton

06/05/2022, 5:53 PM
I was wondering how to implement "user last logged in date" with Supertokens. It seems there is not a feature for this, or I might be blind πŸ˜„ Do I have to update user metadata with new Date() each time the user hits an API endpoint?
r

rp

06/05/2022, 5:54 PM
Do you want to implement user last logged in? Or user last active?
c

CaptainPhoton

06/05/2022, 5:54 PM
either is fine
r

rp

06/05/2022, 5:55 PM
Well, for last logged in, you can simply override the createNewSession function from the session recipe and update the user’s metadata with the current time
c

CaptainPhoton

06/05/2022, 5:55 PM
that sounds good πŸ˜„
r

rp

06/05/2022, 5:55 PM
πŸ‘
c

CaptainPhoton

06/05/2022, 5:56 PM
I think I prefer "last logged in", as to not spam metadata updates
r

rp

06/05/2022, 5:56 PM
You can even override the session refresh function and update the metadata in there. But this would be more like last active (or rather an approximation of that)
c

CaptainPhoton

06/05/2022, 5:57 PM
okay cool, thanks for the tip!