1
0
Fork 0
mirror of https://github.com/Nutomic/ibis.git synced 2024-12-24 00:01:23 +00:00

Fix page load

This commit is contained in:
Felix Ableitner 2024-11-13 10:41:55 +01:00
parent 0e7a45306d
commit d075d15b50
2 changed files with 12 additions and 3 deletions

View file

@ -1,4 +1,4 @@
use super::check_is_admin;
use super::{check_is_admin, is_admin_opt};
use crate::{
backend::{
database::{
@ -161,10 +161,10 @@ pub(in crate::backend::api) async fn edit_article(
#[debug_handler]
pub(in crate::backend::api) async fn get_article(
Query(query): Query<GetArticleForm>,
Extension(user): Extension<LocalUserView>,
user: Option<Extension<LocalUserView>>,
data: Data<IbisData>,
) -> MyResult<Json<ArticleView>> {
let is_admin = check_is_admin(&user).is_ok();
let is_admin = is_admin_opt(&user);
match (query.title, query.id) {
(Some(title), None) => Ok(Json(DbArticle::read_view_title(
&title,

View file

@ -36,6 +36,7 @@ use axum::{
middleware::{self, Next},
response::Response,
routing::{get, post},
Extension,
Router,
};
use axum_extra::extract::CookieJar;
@ -93,3 +94,11 @@ fn check_is_admin(user: &LocalUserView) -> MyResult<()> {
}
Ok(())
}
fn is_admin_opt(user: &Option<Extension<LocalUserView>>) -> bool {
if let Some(user) = user {
user.local_user.admin
} else {
false
}
}