refactor(tokens-repo): delete is_name_exists() from auth utils

redis/token-repo
Houkime 2022-12-21 17:09:49 +00:00
parent 22a309466e
commit 5a1f64b1e7
2 changed files with 1 additions and 8 deletions

View File

@ -11,7 +11,6 @@ from selfprivacy_api.utils.auth import (
get_tokens_info,
is_recovery_token_exists,
is_recovery_token_valid,
is_token_name_exists,
get_token_name,
)
@ -57,7 +56,7 @@ def delete_api_token(caller_token: str, token_name: str) -> None:
"""Delete the token"""
if TOKEN_REPO.is_token_name_pair_valid(token_name, caller_token):
raise CannotDeleteCallerException("Cannot delete caller's token")
if not is_token_name_exists(token_name):
if not TOKEN_REPO.is_token_name_exists(token_name):
raise NotFoundException("Token not found")
delete_token(token_name)

View File

@ -73,12 +73,6 @@ def is_token_valid(token):
return False
def is_token_name_exists(token_name):
"""Check if token name exists"""
with ReadUserData(UserDataFiles.TOKENS) as tokens:
return token_name in [t["name"] for t in tokens["tokens"]]
def get_token_name(token: str) -> typing.Optional[str]:
"""Return the name of the token provided"""
with ReadUserData(UserDataFiles.TOKENS) as tokens: