Add title to cover attribution.
[redakcja.git] / src / redakcja / api / auth.py
1 from django.utils.timezone import now
2 from rest_framework.authentication import TokenAuthentication as BaseTokenAuthentication
3 from . import models
4
5
6 class TokenAuthentication(BaseTokenAuthentication):
7     model = models.Token
8
9     def authenticate_credentials(self, key):
10         user, token = super().authenticate_credentials(key)
11         token.last_seen_at = now()
12         token.save(update_fields=['last_seen_at'])
13         return (user, token)