mirror of
https://github.com/ansible/awx.git
synced 2024-10-31 15:21:13 +03:00
Merge pull request #317 from AlanCoding/token_on_commit
[WIP] delay token expiration update to on_commit
This commit is contained in:
commit
223a198bc4
@ -9,7 +9,7 @@ import uuid
|
||||
|
||||
# Django
|
||||
from django.conf import settings
|
||||
from django.db import models
|
||||
from django.db import models, connection
|
||||
from django.contrib.auth.models import User
|
||||
from django.utils.timezone import now as tz_now
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
@ -187,7 +187,7 @@ class AuthToken(BaseModel):
|
||||
if not self.pk or not self.is_expired(now=now):
|
||||
self.expires = now + datetime.timedelta(seconds=settings.AUTH_TOKEN_EXPIRATION)
|
||||
if save:
|
||||
self.save()
|
||||
connection.on_commit(lambda: self.save(update_fields=['expires']))
|
||||
|
||||
def invalidate(self, reason='timeout_reached', save=True):
|
||||
if not AuthToken.reason_long(reason):
|
||||
|
Loading…
Reference in New Issue
Block a user