fix: simplified admin checking

This commit is contained in:
Per Stark
2026-02-13 23:04:01 +01:00
parent d1b3e9b23a
commit ffae16bc84
3 changed files with 15 additions and 54 deletions
@@ -46,3 +46,14 @@ pub async fn require_auth(auth: AuthSessionType, mut request: Request, next: Nex
}
}
}
pub async fn require_admin(auth: AuthSessionType, mut request: Request, next: Next) -> Response {
match auth.current_user {
Some(user) if user.admin => {
request.extensions_mut().insert(user);
next.run(request).await
}
Some(_) => TemplateResponse::redirect("/").into_response(),
None => TemplateResponse::redirect("/signin").into_response(),
}
}