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

redis/token-repo
Houkime 2022-12-26 10:13:37 +00:00
parent 5dedbda41f
commit 3f6aa9bd06
4 changed files with 6 additions and 9 deletions

View File

@ -110,3 +110,7 @@ def get_new_api_recovery_key(
key = TOKEN_REPO.create_recovery_key(expiration_date, uses_left)
mnemonic_phrase = Mnemonic(language="english").to_mnemonic(bytes.fromhex(key.key))
return mnemonic_phrase
def delete_new_device_auth_token() -> None:
TOKEN_REPO.delete_new_device_key()

View File

@ -12,6 +12,7 @@ from selfprivacy_api.actions.api_tokens import (
delete_api_token,
get_new_api_recovery_key,
refresh_api_token,
delete_new_device_auth_token,
)
from selfprivacy_api.graphql import IsAuthenticated
from selfprivacy_api.graphql.mutations.mutation_interface import (
@ -20,7 +21,6 @@ from selfprivacy_api.graphql.mutations.mutation_interface import (
)
from selfprivacy_api.utils.auth import (
delete_new_device_auth_token,
get_new_device_auth_token,
use_new_device_auth_token,
)

View File

@ -12,12 +12,12 @@ from selfprivacy_api.actions.api_tokens import (
get_api_tokens_with_caller_flag,
get_new_api_recovery_key,
refresh_api_token,
delete_new_device_auth_token,
)
from selfprivacy_api.dependencies import TokenHeader, get_token_header
from selfprivacy_api.utils.auth import (
delete_new_device_auth_token,
get_new_device_auth_token,
use_mnemonic_recoverery_token,
use_new_device_auth_token,

View File

@ -257,13 +257,6 @@ def _get_new_device_auth_token():
return new_device["token"]
def delete_new_device_auth_token():
"""Delete new device auth token"""
with WriteUserData(UserDataFiles.TOKENS) as tokens:
if "new_device" in tokens:
del tokens["new_device"]
def use_new_device_auth_token(mnemonic_phrase, name):
"""Use the new device auth token by converting the mnemonic string to a byte array.
If the mnemonic phrase is valid then generate a device token and return it.