From c5934c6fb811136a265f1ca921ec958e5721e9f5 Mon Sep 17 00:00:00 2001 From: SadlyNotSappho Date: Tue, 19 Mar 2024 13:19:24 -0700 Subject: [PATCH] update GET /adminpanel error messages --- src/main.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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())), } }