Deduplicate dashboard frontend code
This commit is contained in:
@ -849,22 +849,15 @@ pub async fn todos_redirect(id: &str) -> Redirect {
|
|||||||
|
|
||||||
#[get("/")]
|
#[get("/")]
|
||||||
pub async fn dashboard_home(cookies: &CookieJar<'_>) -> DashboardPage {
|
pub async fn dashboard_home(cookies: &CookieJar<'_>) -> DashboardPage {
|
||||||
if cookies.get_private("userid").is_some() {
|
render_dashboard(cookies).await
|
||||||
match NamedFile::open(Path::new(path!("static/index.html"))).await {
|
|
||||||
Ok(f) => DashboardPage::Ok(f),
|
|
||||||
Err(e) => {
|
|
||||||
warn!("Couldn't render dashboard: {:?}", e);
|
|
||||||
|
|
||||||
DashboardPage::NotConfigured(internal_server_error().await)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
DashboardPage::Unauthorised(Redirect::to("/login/discord"))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/<_..>")]
|
#[get("/<_..>")]
|
||||||
pub async fn dashboard(cookies: &CookieJar<'_>) -> DashboardPage {
|
pub async fn dashboard(cookies: &CookieJar<'_>) -> DashboardPage {
|
||||||
|
render_dashboard(cookies).await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn render_dashboard(cookies: &CookieJar<'_>) -> DashboardPage {
|
||||||
if cookies.get_private("userid").is_some() {
|
if cookies.get_private("userid").is_some() {
|
||||||
match NamedFile::open(Path::new(path!("static/index.html"))).await {
|
match NamedFile::open(Path::new(path!("static/index.html"))).await {
|
||||||
Ok(f) => DashboardPage::Ok(f),
|
Ok(f) => DashboardPage::Ok(f),
|
||||||
|
Reference in New Issue
Block a user