mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-01-23 17:26:46 +00:00
refactor(tokens-repo): use token repo in get_api_recovery_token_status action
This commit is contained in:
parent
a2ac47b0f5
commit
f928ca160a
|
@ -6,10 +6,7 @@ from mnemonic import Mnemonic
|
||||||
|
|
||||||
|
|
||||||
from selfprivacy_api.utils.auth import (
|
from selfprivacy_api.utils.auth import (
|
||||||
get_recovery_token_status,
|
|
||||||
get_tokens_info,
|
get_tokens_info,
|
||||||
is_recovery_token_exists,
|
|
||||||
is_recovery_token_valid,
|
|
||||||
get_token_name,
|
get_token_name,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -83,18 +80,16 @@ class RecoveryTokenStatus(BaseModel):
|
||||||
|
|
||||||
def get_api_recovery_token_status() -> RecoveryTokenStatus:
|
def get_api_recovery_token_status() -> RecoveryTokenStatus:
|
||||||
"""Get the recovery token status"""
|
"""Get the recovery token status"""
|
||||||
if not is_recovery_token_exists():
|
token = TOKEN_REPO.get_recovery_key()
|
||||||
|
if token is None:
|
||||||
return RecoveryTokenStatus(exists=False, valid=False)
|
return RecoveryTokenStatus(exists=False, valid=False)
|
||||||
status = get_recovery_token_status()
|
is_valid = TOKEN_REPO.is_recovery_key_valid()
|
||||||
if status is None:
|
|
||||||
return RecoveryTokenStatus(exists=False, valid=False)
|
|
||||||
is_valid = is_recovery_token_valid()
|
|
||||||
return RecoveryTokenStatus(
|
return RecoveryTokenStatus(
|
||||||
exists=True,
|
exists=True,
|
||||||
valid=is_valid,
|
valid=is_valid,
|
||||||
date=status["date"],
|
date=token.created_at,
|
||||||
expiration=status["expiration"],
|
expiration=token.expires_at,
|
||||||
uses_left=status["uses_left"],
|
uses_left=token.uses_left,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue