mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-17 20:46:30 -06:00
Only update every 60 seconds
This commit is contained in:
parent
c04b4bbbfa
commit
5d4575ed25
@ -19,7 +19,9 @@ class TokenAuthentication(authentication.TokenAuthentication):
|
|||||||
except model.DoesNotExist:
|
except model.DoesNotExist:
|
||||||
raise exceptions.AuthenticationFailed("Invalid token")
|
raise exceptions.AuthenticationFailed("Invalid token")
|
||||||
|
|
||||||
# Update last used.
|
# 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.last_used = timezone.now()
|
||||||
token.save()
|
token.save()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user