mirror of
https://github.com/R0m1k3/xtremflow.git
synced 2026-10-11 17:30:00 +02:00
feat: Initialize core database with user, playlist, and session management, and establish initial server and user API handler files.
This commit is contained in:
1 parent
2232565bd8
commit
28d4bef661
3 files changed
+201
-1
No files matched your search
@@ -151,6 +151,34 @@ class AppDatabase {
|
||||
);
|
||||
}
|
||||
|
||||
/// Get all users
|
||||
List<User> getAllUsers() {
|
||||
final result = _db.select('SELECT * FROM users ORDER BY username ASC');
|
||||
return result.map((row) => User.fromMap(row)).toList();
|
||||
}
|
||||
|
||||
/// Update user password
|
||||
void updateUserPassword(String userId, String newPassword) {
|
||||
final passwordHash = PasswordHasher.hash(newPassword);
|
||||
_db.execute(
|
||||
'UPDATE users SET password_hash = ?, updated_at = CURRENT_TIMESTAMP WHERE id = ?',
|
||||
[passwordHash, userId],
|
||||
);
|
||||
}
|
||||
|
||||
/// Update user administration status
|
||||
void updateUserAdminStatus(String userId, bool isAdmin) {
|
||||
_db.execute(
|
||||
'UPDATE users SET is_admin = ?, updated_at = CURRENT_TIMESTAMP WHERE id = ?',
|
||||
[isAdmin ? 1 : 0, userId],
|
||||
);
|
||||
}
|
||||
|
||||
/// Delete user
|
||||
void deleteUser(String userId) {
|
||||
_db.execute('DELETE FROM users WHERE id = ?', [userId]);
|
||||
}
|
||||
|
||||
// ==================== Sessions ====================
|
||||
|
||||
/// Create new session
|
||||
|
||||
Reference in new issue
Block a user