- {archives.map(archive => (
-
-
{archive.label}
-
{archive.archive_path}
-
- ))}
+
Admin
+
+
+
+
+
+
+ {error &&
{error}
}
+
+ {tab === 'users' && (
+
+
Users
+ {loading ?
Loading…
: (
+
+
+ | Username | Email | Roles | Status | Actions |
+
+
+ {users.map(u => (
+
+ | {u.username} |
+ {u.email || '—'} |
+ {u.role_slugs.join(', ') || '—'} |
+ {u.status} |
+
+
+ |
+
+ ))}
+
+
+ )}
+
+
Create User
+
+
+ )}
+
+ {tab === 'roles' && (
+
+
Roles
+ {loading ?
Loading…
: (
+
+
+ | Slug | Name | Level | Bit | Built-in |
+
+
+ {roles.map(r => (
+
+ {r.slug} |
+ {r.name} |
+ {r.level} |
+ {r.bit_position} |
+ {r.is_builtin ? '✓' : ''} |
+
+ ))}
+
+
+ )}
+
+
Create Custom Role
+
+
+ )}
+
+ {tab === 'archives' && (
+
+
Mounted Archives
+
+ {archives.map(a => (
+
+
{a.label}
+
{a.archive_path}
+
+ ))}
+
+
+ )}
)
}
From 48da356eee7dfb994eedb6c48601087d17d4c56d Mon Sep 17 00:00:00 2001
From: TheGeneralist <180094941+thegeneralist01@users.noreply.github.com>
Date: Fri, 26 Jun 2026 15:03:40 +0200
Subject: [PATCH 2/4] feat(users): user management DB helpers (list_users,
create_user, assign_role, custom roles)
---
crates/archivr-core/src/database.rs | 299 ++++++++++++++++++++++++++++
1 file changed, 299 insertions(+)
diff --git a/crates/archivr-core/src/database.rs b/crates/archivr-core/src/database.rs
index b23d782..87a1fd0 100644
--- a/crates/archivr-core/src/database.rs
+++ b/crates/archivr-core/src/database.rs
@@ -109,6 +109,27 @@ pub struct CaptureJobRecord {
pub updated_at: String,
}
+#[derive(Debug, Clone, serde::Serialize)]
+pub struct UserSummary {
+ pub user_uid: String,
+ pub username: String,
+ pub email: Option
,
+ pub status: String,
+ pub created_at: String,
+ pub role_slugs: Vec,
+ pub role_bits: u32,
+}
+
+#[derive(Debug, Clone, serde::Serialize)]
+pub struct RoleRecord {
+ pub role_uid: String,
+ pub slug: String,
+ pub name: String,
+ pub level: i64,
+ pub bit_position: i64,
+ pub is_builtin: bool,
+}
+
pub fn database_path(archive_path: &Path) -> PathBuf {
archive_path.join(DATABASE_FILE_NAME)
}
@@ -577,6 +598,225 @@ pub fn list_user_tokens(conn: &Connection, user_id: i64) -> Result Result {
+ let n = conn.execute("DELETE FROM sessions WHERE user_id = ?1", [user_id])?;
+ Ok(n)
+}
+
+/// Returns the integer id for a user_uid, or None if not found.
+pub fn get_user_id_by_uid(conn: &Connection, user_uid: &str) -> Result