poprawki i zmiany ux

This commit is contained in:
Mateusz Gruszczyński
2026-03-26 09:30:39 +01:00
parent fd0f645251
commit 138059945e
28 changed files with 1000 additions and 225 deletions

View File

@@ -108,6 +108,23 @@ class SQLiteAuthUserRepository:
return None
return self.get_by_username(username)
def update_role(self, username: str, role: str) -> AuthUser | None:
now = datetime.utcnow().isoformat()
with self.connect() as conn:
cursor = conn.execute(
"UPDATE auth_users SET role = ?, updated_at = ? WHERE username = ?",
(role, now, username),
)
if cursor.rowcount == 0:
return None
return self.get_by_username(username)
def count_admin_users(self) -> int:
with self.connect() as conn:
row = conn.execute(
"SELECT COUNT(*) AS count FROM auth_users WHERE role = 'admin' AND is_active = 1"
).fetchone()
return int(row['count']) if row is not None else 0
def list_users(self) -> list[AuthUser]:
with self.connect() as conn: