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;
9use serde::Deserialize;
10
11pub(crate) const LOG_UI: &str = "fm::ui";
12
13pub const EXPLORER_IDX_ROUTE: &str = "/explorer";
15pub const EXPLORER_ROUTE: &str = "/explorer/{session_idx}";
16pub const DOWNLOAD_BACKUP_ROUTE: &str = "/download-backup";
17pub const CHANGE_PASSWORD_ROUTE: &str = "/change-password";
18pub const METRICS_ROUTE: &str = "/metrics";
19
20#[derive(Debug, Deserialize)]
21pub struct PasswordChangeInput {
22 pub current_password: String,
23 pub new_password: String,
24 pub confirm_password: String,
25}
26
27pub(crate) fn login_submit_response(
28 auth: ApiAuth,
29 auth_cookie_name: String,
30 auth_cookie_value: String,
31 jar: CookieJar,
32 input: LoginInput,
33) -> impl IntoResponse {
34 if auth.0 == input.password {
35 let mut cookie = Cookie::new(auth_cookie_name, auth_cookie_value);
36
37 cookie.set_http_only(true);
38 cookie.set_same_site(Some(SameSite::Lax));
39
40 return (jar.add(cookie), Redirect::to("/")).into_response();
41 }
42
43 let content = html! {
44 div class="alert alert-danger" { "The password is invalid" }
45 div class="button-container" {
46 a href="/login" class="btn btn-primary setup-btn" { "Return to Login" }
47 }
48 };
49
50 Html(login_layout("Login Failed", content).into_string()).into_response()
51}