Renamed columns in tables
MasterPass passwd -> password_hash Account enc_pass -> enc_password
This commit is contained in:
parent
04bb306751
commit
0d3965d5d2
@ -7,14 +7,14 @@ import pydantic
|
|||||||
class _Account(pydantic.BaseModel):
|
class _Account(pydantic.BaseModel):
|
||||||
name: str
|
name: str
|
||||||
login: str
|
login: str
|
||||||
passwd: str
|
password: str
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_tuple(cls: Type[Self], tuple_: tuple[str, str, str]) -> Self:
|
def from_tuple(cls: Type[Self], tuple_: tuple[str, str, str]) -> Self:
|
||||||
return cls(name=tuple_[0], login=tuple_[1], passwd=tuple_[2])
|
return cls(name=tuple_[0], login=tuple_[1], passwd=tuple_[2])
|
||||||
|
|
||||||
def as_tuple(self: Self) -> tuple[str, str, str]:
|
def as_tuple(self: Self) -> tuple[str, str, str]:
|
||||||
return (self.name, self.login, self.passwd)
|
return (self.name, self.login, self.password)
|
||||||
|
|
||||||
|
|
||||||
class _Accounts(pydantic.BaseModel):
|
class _Accounts(pydantic.BaseModel):
|
||||||
|
@ -19,7 +19,7 @@ def add_account(
|
|||||||
name=name,
|
name=name,
|
||||||
salt=salt,
|
salt=salt,
|
||||||
enc_login=enc_login,
|
enc_login=enc_login,
|
||||||
enc_pass=enc_password,
|
enc_password=enc_password,
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
with sqlmodel.Session(engine) as session:
|
with sqlmodel.Session(engine) as session:
|
||||||
@ -41,7 +41,7 @@ def add_master_pass(
|
|||||||
master_pass = models.MasterPass(
|
master_pass = models.MasterPass(
|
||||||
user_id=user_id,
|
user_id=user_id,
|
||||||
salt=salt,
|
salt=salt,
|
||||||
passwd=password_hash,
|
password_hash=password_hash,
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
with sqlmodel.Session(engine) as session:
|
with sqlmodel.Session(engine) as session:
|
||||||
|
@ -19,7 +19,7 @@ def get_master_pass(
|
|||||||
result = session.exec(statement).first()
|
result = session.exec(statement).first()
|
||||||
if result is None:
|
if result is None:
|
||||||
return
|
return
|
||||||
return (result.salt, result.passwd)
|
return (result.salt, result.password_hash)
|
||||||
|
|
||||||
|
|
||||||
def get_accounts(engine: Engine, user_id: int) -> list[str]:
|
def get_accounts(engine: Engine, user_id: int) -> list[str]:
|
||||||
@ -43,7 +43,7 @@ def get_all_accounts(
|
|||||||
with sqlmodel.Session(engine) as session:
|
with sqlmodel.Session(engine) as session:
|
||||||
result = session.exec(statement)
|
result = session.exec(statement)
|
||||||
yield from (
|
yield from (
|
||||||
(account.name, account.salt, account.enc_login, account.enc_pass)
|
(account.name, account.salt, account.enc_login, account.enc_password)
|
||||||
for account in result
|
for account in result
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -61,4 +61,4 @@ def get_account_info(
|
|||||||
result = session.exec(statement).first()
|
result = session.exec(statement).first()
|
||||||
if result is None:
|
if result is None:
|
||||||
return
|
return
|
||||||
return (result.salt, result.enc_login, result.enc_pass)
|
return (result.salt, result.enc_login, result.enc_password)
|
||||||
|
@ -10,7 +10,7 @@ class MasterPass(sqlmodel.SQLModel, table=True):
|
|||||||
salt: bytes = sqlmodel.Field(
|
salt: bytes = sqlmodel.Field(
|
||||||
sa_column=sqlmodel.Column(sqlmodel.BINARY(64), nullable=False)
|
sa_column=sqlmodel.Column(sqlmodel.BINARY(64), nullable=False)
|
||||||
)
|
)
|
||||||
passwd: bytes = sqlmodel.Field(
|
password_hash: bytes = sqlmodel.Field(
|
||||||
sa_column=sqlmodel.Column(sqlmodel.BINARY(128), nullable=False)
|
sa_column=sqlmodel.Column(sqlmodel.BINARY(128), nullable=False)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -27,6 +27,6 @@ class Account(sqlmodel.SQLModel, table=True):
|
|||||||
enc_login: bytes = sqlmodel.Field(
|
enc_login: bytes = sqlmodel.Field(
|
||||||
sa_column=sqlmodel.Column(sqlmodel.VARBINARY(256), nullable=False)
|
sa_column=sqlmodel.Column(sqlmodel.VARBINARY(256), nullable=False)
|
||||||
)
|
)
|
||||||
enc_pass: bytes = sqlmodel.Field(
|
enc_password: bytes = sqlmodel.Field(
|
||||||
sa_column=sqlmodel.Column(sqlmodel.VARBINARY(256), nullable=False)
|
sa_column=sqlmodel.Column(sqlmodel.VARBINARY(256), nullable=False)
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user