iMerica / dj-rest-auth

Authentication for Django Rest Framework
https://dj-rest-auth.readthedocs.io/en/latest/index.html
MIT License
1.63k stars 304 forks source link

Last Login Is Never Updated For USE_JWT True #531

Open Aniket-Singla opened 11 months ago

Aniket-Singla commented 11 months ago

Hi everyone,

I see a bug where last_login is never updated in db if we use jwt login.

Changes are expected in https://github.com/iMerica/dj-rest-auth/blob/8a2e07de1a5b166d99fa3cf2995561773c29333f/dj_rest_auth/utils.py#L9C22-L9C22 where I see we are not using the validate method of serializer and directly using get_token class method. So, maybe we should call dajngo's signal here after generating tokens : update_last_login(None, self.user)

But that would again be conditional because the same util function is used in Registration flow and for some applications, login might not succeed until email or some other verifications are done. Ignore last line because that check is already present in Registration view.