poprawki i zmiany ux
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user