Update last_login in each api call

remotes/origin/3.4.0rc
Jesús Espino 2017-10-27 10:42:59 +02:00
parent 49650db332
commit 0ede2a67be
1 changed files with 6 additions and 0 deletions

View File

@ -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):