mirror of
https://github.com/ansible/awx.git
synced 2026-02-26 15:36:04 -03:30
Merge pull request #4695 from ryanpetrello/oauth-token-exclusive-lock
move the oauth2 last_used update to the bottom of the request Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
@@ -3,7 +3,7 @@ import re
|
|||||||
|
|
||||||
# Django
|
# Django
|
||||||
from django.core.validators import RegexValidator
|
from django.core.validators import RegexValidator
|
||||||
from django.db import models
|
from django.db import models, connection
|
||||||
from django.utils.timezone import now
|
from django.utils.timezone import now
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@@ -121,7 +121,7 @@ class OAuth2AccessToken(AbstractAccessToken):
|
|||||||
valid = super(OAuth2AccessToken, self).is_valid(scopes)
|
valid = super(OAuth2AccessToken, self).is_valid(scopes)
|
||||||
if valid:
|
if valid:
|
||||||
self.last_used = now()
|
self.last_used = now()
|
||||||
self.save(update_fields=['last_used'])
|
connection.on_commit(lambda: self.save(update_fields=['last_used']))
|
||||||
return valid
|
return valid
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
|
|||||||
Reference in New Issue
Block a user