diff --git a/src/main.rs b/src/main.rs index c22fd0c..97677aa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -158,25 +158,25 @@ async fn logout(cookies: &CookieJar<'_>) -> status::Custom<&'static str> { } #[get("/adminpanel")] -async fn adminpanel(mut db: Connection, cookies: &CookieJar<'_>) -> RawHtml { +async fn adminpanel(mut db: Connection, cookies: &CookieJar<'_>) -> status::Custom> { let token = cookies.get_private("token"); match token { Some(t) => match User::get_by_token(&mut db, t).await { Some(user) => match user.admin { - true => RawHtml( + true => status::Custom(Status::Ok, RawHtml( fs::read_to_string("/srv/web/adminpanel.html") .unwrap() - .replace("{{username}}", &user.username[..]), + .replace("{{username}}", &user.username[..])), ), - false => RawHtml(fs::read_to_string("/srv/web/invalidperms.html").unwrap()), + false => status::Custom(Status::Unauthorized, RawHtml(fs::read_to_string("/srv/web/invalidperms.html").unwrap())), }, - None => RawHtml( + None => status::Custom(Status::Unauthorized, RawHtml( fs::read_to_string("/srv/web/error.html") .unwrap() - .replace("{{errorcode}}", "498"), + .replace("{{errorcode}}", "401")), ), }, - None => RawHtml(fs::read_to_string("/srv/web/invalidperms.html").unwrap()), + None => status::Custom(Status::Unauthorized, RawHtml(fs::read_to_string("/srv/web/invalidperms.html").unwrap())), } }