mirror of
https://github.com/Casvt/MIND.git
synced 2026-04-03 03:00:22 -04:00
Added 2FA in the backend
This commit is contained in:
@@ -387,7 +387,8 @@ DB_SCHEMA = """
|
||||
username VARCHAR(255) UNIQUE NOT NULL,
|
||||
salt VARCHAR(40) NOT NULL,
|
||||
hash VARCHAR(100) NOT NULL,
|
||||
admin BOOL NOT NULL DEFAULT 0
|
||||
admin BOOL NOT NULL DEFAULT 0,
|
||||
mfa_apprise_url TEXT
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS notification_services(
|
||||
id INTEGER PRIMARY KEY,
|
||||
|
||||
@@ -382,3 +382,16 @@ class MigrateAddCronScheduleColumn(DBMigrator):
|
||||
COMMIT;
|
||||
PRAGMA foreign_keys = ON;
|
||||
""")
|
||||
|
||||
|
||||
class MigrateAddMFAColumn(DBMigrator):
|
||||
start_version = 13
|
||||
|
||||
def run(self) -> None:
|
||||
# V13 -> V14
|
||||
|
||||
get_db().executescript("""
|
||||
ALTER TABLE users
|
||||
ADD mfa_apprise_url TEXT;
|
||||
""")
|
||||
return
|
||||
|
||||
@@ -275,7 +275,7 @@ class UsersDB:
|
||||
|
||||
result = get_db().execute(f"""
|
||||
SELECT
|
||||
id, username, admin, salt, hash
|
||||
id, username, admin, salt, hash, mfa_apprise_url
|
||||
FROM users
|
||||
{id_filter}
|
||||
ORDER BY admin DESC, LOWER(username);
|
||||
@@ -310,16 +310,20 @@ class UsersDB:
|
||||
self,
|
||||
user_id: int,
|
||||
username: str,
|
||||
hash: bytes
|
||||
hash: bytes,
|
||||
mfa_apprise_url: Union[str, None]
|
||||
) -> None:
|
||||
get_db().execute("""
|
||||
UPDATE users
|
||||
SET username = :username, hash = :hash
|
||||
SET username = :username,
|
||||
hash = :hash,
|
||||
mfa_apprise_url = :mfa_apprise_url
|
||||
WHERE id = :user_id;
|
||||
""",
|
||||
{
|
||||
"username": username,
|
||||
"hash": hash,
|
||||
"mfa_apprise_url": mfa_apprise_url or None,
|
||||
"user_id": user_id
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user