Add endpoint to get current user
This commit is contained in:
@@ -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))
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user