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

redis/token-repo
Houkime 2022-12-23 11:14:52 +00:00
parent 5a1f64b1e7
commit a2ac47b0f5
2 changed files with 2 additions and 8 deletions

View File

@ -6,7 +6,6 @@ from mnemonic import Mnemonic
from selfprivacy_api.utils.auth import (
delete_token,
get_recovery_token_status,
get_tokens_info,
is_recovery_token_exists,
@ -58,7 +57,8 @@ def delete_api_token(caller_token: str, token_name: str) -> None:
raise CannotDeleteCallerException("Cannot delete caller's token")
if not TOKEN_REPO.is_token_name_exists(token_name):
raise NotFoundException("Token not found")
delete_token(token_name)
token = TOKEN_REPO.get_token_by_name(token_name)
TOKEN_REPO.delete_token(token)
def refresh_api_token(caller_token: str) -> str:

View File

@ -124,12 +124,6 @@ def create_token(name):
return token
def delete_token(token_name):
"""Delete token"""
with WriteUserData(UserDataFiles.TOKENS) as tokens:
tokens["tokens"] = [t for t in tokens["tokens"] if t["name"] != token_name]
def is_recovery_token_exists():
"""Check if recovery token exists"""
with ReadUserData(UserDataFiles.TOKENS) as tokens: