mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Only update every 60 seconds
This commit is contained in:
@ -19,9 +19,11 @@ class TokenAuthentication(authentication.TokenAuthentication):
|
||||
except model.DoesNotExist:
|
||||
raise exceptions.AuthenticationFailed("Invalid token")
|
||||
|
||||
# Update last used.
|
||||
token.last_used = timezone.now()
|
||||
token.save()
|
||||
# Update last used, but only once a minute. This reduces the write load on the db
|
||||
timediff = timezone.now() - token.last_used
|
||||
if timediff.total_seconds() > 60:
|
||||
token.last_used = timezone.now()
|
||||
token.save()
|
||||
|
||||
# Enforce the Token's expiration time, if one has been set.
|
||||
if token.is_expired:
|
||||
|
Reference in New Issue
Block a user