Added checks to /import
This commit is contained in:
parent
b56ebd0b61
commit
03646b6156
@ -12,6 +12,7 @@ from .utils import (
|
|||||||
check_account_name,
|
check_account_name,
|
||||||
check_login,
|
check_login,
|
||||||
check_passwd,
|
check_passwd,
|
||||||
|
check_account,
|
||||||
get_all_accounts,
|
get_all_accounts,
|
||||||
json_to_accounts,
|
json_to_accounts,
|
||||||
send_tmp_message,
|
send_tmp_message,
|
||||||
@ -437,9 +438,13 @@ def _import3(
|
|||||||
if cryptography.master_pass.encrypt_master_pass(text, master_salt) != hash_pass:
|
if cryptography.master_pass.encrypt_master_pass(text, master_salt) != hash_pass:
|
||||||
return send_tmp_message(bot, mes.chat.id, "Не подходит мастер пароль")
|
return send_tmp_message(bot, mes.chat.id, "Не подходит мастер пароль")
|
||||||
|
|
||||||
|
# List of names of accounts, which failed to be added to the database or failed tests
|
||||||
failed: list[str] = []
|
failed: list[str] = []
|
||||||
for account in accounts:
|
for account in accounts:
|
||||||
name, login, passwd = account
|
name, login, passwd = account
|
||||||
|
if not check_account(name, login, passwd):
|
||||||
|
failed.append(name)
|
||||||
|
continue
|
||||||
enc_login, enc_passwd, salt = cryptography.other_accounts.encrypt_account_info(
|
enc_login, enc_passwd, salt = cryptography.other_accounts.encrypt_account_info(
|
||||||
login, passwd, text.encode("utf-8")
|
login, passwd, text.encode("utf-8")
|
||||||
)
|
)
|
||||||
|
@ -95,3 +95,8 @@ def check_login(login: str) -> bool:
|
|||||||
def check_passwd(passwd: str) -> bool:
|
def check_passwd(passwd: str) -> bool:
|
||||||
"Returns true if password is valid"
|
"Returns true if password is valid"
|
||||||
return _base_check(passwd)
|
return _base_check(passwd)
|
||||||
|
|
||||||
|
|
||||||
|
def check_account(name: str, login: str, passwd: str) -> bool:
|
||||||
|
"""Runs checks for account name, login and password"""
|
||||||
|
return check_account_name(name) and check_login(login) and check_passwd(passwd)
|
||||||
|
Reference in New Issue
Block a user