use leptos::*; use leptos_router::*; use super::auth_base::AuthBase; #[server] async fn forgot_action(email: String) -> Result<(), ServerFnError> { use crate::domain::api::prelude::*; let email = EmailAddress::new(&email).map_err(|_| format!("\"{}\" is not a email address", email))?; let app = use_context::().unwrap(); let flashbag = use_context::().unwrap(); // If the email address is known, we'll set a recovery link, if it's not, we wont, but the flash remains the same. app.forgot_password(&email).await; let flash = FlashMessage::new("login", format!( "An e-mail has been sent to {} with a link to reset your password.", email )).with_alert(Alert::Success); flashbag.set(flash); leptos_axum::redirect("/auth/login"); Ok(()) } /// Renders the home page of your application. #[component] pub fn ForgotPage() -> impl IntoView { let submit = Action::::server(); let response = submit.value().read_only(); view! {
"New Account? Sign up ""here""!"
"Remembered your password? Login ""here""!"
} .into_view() }