fedimint_server_ui/
lib.rs1pub mod dashboard;
2pub mod setup;
3
4use axum::response::{Html, IntoResponse, Redirect};
5use axum_extra::extract::cookie::{Cookie, CookieJar, SameSite};
6use fedimint_core::module::ApiAuth;
7use fedimint_ui_common::{LoginInput, common_head, login_layout};
8use maud::html;
9
10pub(crate) const LOG_UI: &str = "fm::ui";
11
12pub const EXPLORER_IDX_ROUTE: &str = "/explorer";
14pub const EXPLORER_ROUTE: &str = "/explorer/{session_idx}";
15pub const DOWNLOAD_BACKUP_ROUTE: &str = "/download-backup";
16
17pub(crate) fn login_submit_response(
18 auth: ApiAuth,
19 auth_cookie_name: String,
20 auth_cookie_value: String,
21 jar: CookieJar,
22 input: LoginInput,
23) -> impl IntoResponse {
24 if auth.0 == input.password {
25 let mut cookie = Cookie::new(auth_cookie_name, auth_cookie_value);
26
27 cookie.set_http_only(true);
28 cookie.set_same_site(Some(SameSite::Lax));
29
30 return (jar.add(cookie), Redirect::to("/")).into_response();
31 }
32
33 let content = html! {
34 div class="alert alert-danger" { "The password is invalid" }
35 div class="button-container" {
36 a href="/login" class="btn btn-primary setup-btn" { "Return to Login" }
37 }
38 };
39
40 Html(login_layout("Login Failed", content).into_string()).into_response()
41}