mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-18 08:29:14 +00:00
refactor(tokens-repo): use token repo in get_api_tokens_with_caller_flag
This commit is contained in:
parent
f928ca160a
commit
e817de6228
|
@ -4,12 +4,6 @@ from typing import Optional
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from mnemonic import Mnemonic
|
from mnemonic import Mnemonic
|
||||||
|
|
||||||
|
|
||||||
from selfprivacy_api.utils.auth import (
|
|
||||||
get_tokens_info,
|
|
||||||
get_token_name,
|
|
||||||
)
|
|
||||||
|
|
||||||
from selfprivacy_api.repositories.tokens.json_tokens_repository import (
|
from selfprivacy_api.repositories.tokens.json_tokens_repository import (
|
||||||
JsonTokensRepository,
|
JsonTokensRepository,
|
||||||
)
|
)
|
||||||
|
@ -28,13 +22,13 @@ class TokenInfoWithIsCaller(BaseModel):
|
||||||
|
|
||||||
def get_api_tokens_with_caller_flag(caller_token: str) -> list[TokenInfoWithIsCaller]:
|
def get_api_tokens_with_caller_flag(caller_token: str) -> list[TokenInfoWithIsCaller]:
|
||||||
"""Get the tokens info"""
|
"""Get the tokens info"""
|
||||||
caller_name = get_token_name(caller_token)
|
caller_name = TOKEN_REPO.get_token_by_token_string(caller_token).device_name
|
||||||
tokens = get_tokens_info()
|
tokens = TOKEN_REPO.get_tokens()
|
||||||
return [
|
return [
|
||||||
TokenInfoWithIsCaller(
|
TokenInfoWithIsCaller(
|
||||||
name=token.name,
|
name=token.device_name,
|
||||||
date=token.date,
|
date=token.created_at,
|
||||||
is_caller=token.name == caller_name,
|
is_caller=token.device_name == caller_name,
|
||||||
)
|
)
|
||||||
for token in tokens
|
for token in tokens
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue