diff --git a/src/web/routes/dashboard/mod.rs b/src/web/routes/dashboard/mod.rs index 745d132..364abb7 100644 --- a/src/web/routes/dashboard/mod.rs +++ b/src/web/routes/dashboard/mod.rs @@ -849,22 +849,15 @@ pub async fn todos_redirect(id: &str) -> Redirect { #[get("/")] pub async fn dashboard_home(cookies: &CookieJar<'_>) -> DashboardPage { - if cookies.get_private("userid").is_some() { - 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")) - } + render_dashboard(cookies).await } #[get("/<_..>")] 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() { match NamedFile::open(Path::new(path!("static/index.html"))).await { Ok(f) => DashboardPage::Ok(f),