Update last_login in each api call
parent
62bdc296ae
commit
5bc9c06f08
|
@ -37,6 +37,8 @@ fraudulent modifications.
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from django.utils import timezone
|
||||||
|
from datetime import timedelta
|
||||||
from taiga.base.api.authentication import BaseAuthentication
|
from taiga.base.api.authentication import BaseAuthentication
|
||||||
|
|
||||||
from .tokens import get_user_for_token
|
from .tokens import get_user_for_token
|
||||||
|
@ -86,6 +88,10 @@ class Token(BaseAuthentication):
|
||||||
user = get_user_for_token(token, "authentication",
|
user = get_user_for_token(token, "authentication",
|
||||||
max_age=max_age_auth_token)
|
max_age=max_age_auth_token)
|
||||||
|
|
||||||
|
if user.last_login < (timezone.now() - timedelta(minutes=1)):
|
||||||
|
user.last_login = timezone.now()
|
||||||
|
user.save(update_fields=["last_login"])
|
||||||
|
|
||||||
return (user, token)
|
return (user, token)
|
||||||
|
|
||||||
def authenticate_header(self, request):
|
def authenticate_header(self, request):
|
||||||
|
|
Loading…
Reference in New Issue