fix: auth for admin

This commit is contained in:
Evan Carroll 2026-01-22 22:03:27 -06:00
parent 6fb90e42c3
commit a2a0fe5510
9 changed files with 129 additions and 46 deletions

View file

@ -108,6 +108,10 @@ mod server {
// Shared assets directory for uploaded files (realm images, etc.)
let assets_dir = Path::new("/srv/chattyness/assets");
// Create admin connection layer for RLS context
let admin_conn_layer =
chattyness_admin_ui::auth::AdminConnLayer::new(pool.clone());
// Build the app
let app = Router::new()
// Redirect root to admin
@ -115,7 +119,9 @@ mod server {
// Nest API routes under /api/admin (matches frontend expectations when UI is at /admin)
.nest(
"/api/admin",
chattyness_admin_ui::api::admin_api_router().with_state(app_state.clone()),
chattyness_admin_ui::api::admin_api_router()
.layer(admin_conn_layer)
.with_state(app_state.clone()),
)
// Uploaded assets (realm backgrounds, props, etc.) - must come before /static
.nest_service("/assets/server", ServeDir::new(assets_dir.join("server")))