update GET /adminpanel error messages
This commit is contained in:
parent
68e18b89a1
commit
c5934c6fb8
14
src/main.rs
14
src/main.rs
|
@ -158,25 +158,25 @@ async fn logout(cookies: &CookieJar<'_>) -> status::Custom<&'static str> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/adminpanel")]
|
#[get("/adminpanel")]
|
||||||
async fn adminpanel(mut db: Connection<Db>, cookies: &CookieJar<'_>) -> RawHtml<String> {
|
async fn adminpanel(mut db: Connection<Db>, cookies: &CookieJar<'_>) -> status::Custom<RawHtml<String>> {
|
||||||
let token = cookies.get_private("token");
|
let token = cookies.get_private("token");
|
||||||
match token {
|
match token {
|
||||||
Some(t) => match User::get_by_token(&mut db, t).await {
|
Some(t) => match User::get_by_token(&mut db, t).await {
|
||||||
Some(user) => match user.admin {
|
Some(user) => match user.admin {
|
||||||
true => RawHtml(
|
true => status::Custom(Status::Ok, RawHtml(
|
||||||
fs::read_to_string("/srv/web/adminpanel.html")
|
fs::read_to_string("/srv/web/adminpanel.html")
|
||||||
.unwrap()
|
.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")
|
fs::read_to_string("/srv/web/error.html")
|
||||||
.unwrap()
|
.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())),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue