mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-17 08:02:36 +00:00
fix: Migration from secrets to token
This commit is contained in:
parent
8ccec53740
commit
8791462f87
|
@ -1,4 +1,7 @@
|
||||||
|
from datetime import datetime
|
||||||
|
from typing import Optional
|
||||||
from selfprivacy_api.migrations.migration import Migration
|
from selfprivacy_api.migrations.migration import Migration
|
||||||
|
from selfprivacy_api.models.tokens.token import Token
|
||||||
|
|
||||||
from selfprivacy_api.repositories.tokens.redis_tokens_repository import (
|
from selfprivacy_api.repositories.tokens.redis_tokens_repository import (
|
||||||
RedisTokensRepository,
|
RedisTokensRepository,
|
||||||
|
@ -23,10 +26,14 @@ class WriteTokenToRedis(Migration):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def get_token_from_json(self):
|
def get_token_from_json(self) -> Optional[Token]:
|
||||||
try:
|
try:
|
||||||
with ReadUserData(UserDataFiles.SECRETS) as userdata:
|
with ReadUserData(UserDataFiles.SECRETS) as userdata:
|
||||||
return userdata["api"]["token"]
|
return Token(
|
||||||
|
token=userdata["api"]["token"],
|
||||||
|
device_name="Initial device",
|
||||||
|
created_at=datetime.now(),
|
||||||
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
return None
|
return None
|
||||||
|
|
Loading…
Reference in a new issue