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