Compare commits
2 Commits
b0599c1484
...
025ea868a6
Author | SHA1 | Date | |
---|---|---|---|
025ea868a6 | |||
d82d152fef |
@ -23,7 +23,7 @@ class _Accounts(pydantic.BaseModel):
|
||||
|
||||
def _accounts_list_to_json(accounts: Iterator[tuple[str, str, str]]) -> str:
|
||||
accounts = _Accounts(accounts=[_Account.from_tuple(i) for i in accounts])
|
||||
return accounts.json()
|
||||
return accounts.json(ensure_ascii=False)
|
||||
|
||||
|
||||
def json_to_accounts(json_: str) -> list[tuple[str, str, str]]:
|
||||
|
@ -24,9 +24,13 @@ def get_master_pass(
|
||||
|
||||
def get_accounts(engine: Engine, user_id: int) -> list[str]:
|
||||
"""Gets list of account names"""
|
||||
statement = sqlmodel.select(models.Account).where(
|
||||
statement = (
|
||||
sqlmodel.select(models.Account)
|
||||
.where(
|
||||
models.Account.user_id == user_id,
|
||||
)
|
||||
.order_by(models.Account.name)
|
||||
)
|
||||
with sqlmodel.Session(engine) as session:
|
||||
result = session.exec(statement)
|
||||
return [account.name for account in result]
|
||||
@ -37,9 +41,13 @@ def get_all_accounts(
|
||||
) -> Iterator[tuple[str, bytes, bytes, bytes]]:
|
||||
"""Returns an iterator of tuples, where values represent account's
|
||||
name, salt, encrypted login and encrypted password"""
|
||||
statement = sqlmodel.select(models.Account).where(
|
||||
statement = (
|
||||
sqlmodel.select(models.Account)
|
||||
.where(
|
||||
models.Account.user_id == user_id,
|
||||
)
|
||||
.order_by(models.Account.name)
|
||||
)
|
||||
with sqlmodel.Session(engine) as session:
|
||||
result = session.exec(statement)
|
||||
yield from (
|
||||
|
Reference in New Issue
Block a user