Add endpoint to get current user

This commit is contained in:
2026-06-29 19:31:04 -04:00
parent 280d63ed71
commit b0d5c45caf
2 changed files with 8 additions and 1 deletions

View File

@@ -80,3 +80,9 @@ pub async fn logout() -> Result<()> {
}
.err_context("Error logging out")
}
/// Retrieve the currently logged-in user, or `None` if unauthenticated
#[get("/api/v1/auth/user", auth: Extension<AuthSession>)]
pub async fn get_user() -> Result<Option<User>> {
Ok(auth.user.clone().map(Into::into))
}

View File

@@ -13,11 +13,12 @@ const ALLOWED_PATH_PREFIX: [&str; 1] = ["/assets/"];
#[cfg(debug_assertions)]
const ALLOWED_PATH_PREFIX: [&str; 2] = ["/assets/", "/wasm/"];
const ALLOWED_PATHS: [&str; 5] = [
const ALLOWED_PATHS: [&str; 6] = [
"/login",
"/signup",
"/api/v1/auth/login",
"/api/v1/auth/signup",
"/api/v1/auth/user",
"/favicon.ico",
];