mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-18 16:39:13 +00:00
refactor(tokens-repo): delete is_name_exists() from auth utils
This commit is contained in:
parent
22a309466e
commit
5a1f64b1e7
|
@ -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)
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue