mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-25 21:41:27 +00:00
refactor(tokens-repo): rewrite token refresh
now it is not json-dependent.
This commit is contained in:
parent
27a7c24bc3
commit
572ec75c39
|
@ -71,15 +71,9 @@ class JsonTokensRepository(AbstractTokensRepository):
|
|||
"""Change the token field of the existing token"""
|
||||
new_token = Token.generate(device_name=input_token.device_name)
|
||||
|
||||
with WriteUserData(UserDataFiles.TOKENS) as tokens_file:
|
||||
for userdata_token in tokens_file["tokens"]:
|
||||
|
||||
if userdata_token["name"] == input_token.device_name:
|
||||
userdata_token["token"] = new_token.token
|
||||
userdata_token["date"] = (
|
||||
new_token.created_at.strftime(DATETIME_FORMAT),
|
||||
)
|
||||
|
||||
if input_token in self.get_tokens():
|
||||
self.delete_token(input_token)
|
||||
self.__store_token(new_token)
|
||||
return new_token
|
||||
|
||||
raise TokenNotFound("Token not found!")
|
||||
|
|
Loading…
Reference in a new issue