Change /send_password_reset to /forgot_password

This commit is contained in:
notplants 2021-11-10 12:33:37 +01:00
parent e3640f0885
commit a4f459e1fc
5 changed files with 14 additions and 9 deletions

View File

@ -3,7 +3,6 @@ use crate::config_manager::{get_peachcloud_domain, load_peach_config,
get_temporary_password_hash, set_temporary_password_hash};
use crate::error::PeachError;
use crate::sbot_client;
use log::info;
use rand::distributions::Alphanumeric;
use rand::{thread_rng, Rng};
use std::iter;

View File

@ -90,7 +90,7 @@ fn init_rocket() -> Rocket<Build> {
change_password_post, // WEB ROUTE
reset_password, // WEB ROUTE
reset_password_post, // WEB ROUTE
send_password_reset_page, // WEB ROUTE
forgot_password_page, // WEB ROUTE
send_password_reset_post, // WEB ROUTE
configure_admin, // WEB ROUTE
add_admin, // WEB ROUTE

View File

@ -302,9 +302,11 @@ impl SendPasswordResetContext {
}
}
/// Password reset request handler. This route is used by a user who is not logged in to send a new password reset link.
#[get("/send_password_reset")]
pub fn send_password_reset_page(flash: Option<FlashMessage>) -> Template {
/// Page for users who have forgotten their password.
/// This route is used by a user who is not logged in
/// to initiate the sending of a new password reset.
#[get("/forgot_password")]
pub fn forgot_password_page(flash: Option<FlashMessage>) -> Template {
let mut context = SendPasswordResetContext::build();
context.back = Some("/".to_string());
context.title = Some("Send Password Reset".to_string());
@ -314,7 +316,7 @@ pub fn send_password_reset_page(flash: Option<FlashMessage>) -> Template {
context.flash_name = Some(flash.kind().to_string());
context.flash_msg = Some(flash.message().to_string());
};
Template::render("password/send_password_reset", &context)
Template::render("password/forgot_password", &context)
}
/// Send password reset request handler. This route is used by a user who is not logged in
@ -333,7 +335,7 @@ pub fn send_password_reset_post() -> Template {
let flash_msg =
"A password reset link has been sent to the admin of this device".to_string();
context.flash_msg = Some(flash_msg);
Template::render("password/send_password_reset", &context)
Template::render("password/forgot_password", &context)
}
Err(err) => {
let mut context = ChangePasswordContext::build();
@ -341,7 +343,7 @@ pub fn send_password_reset_post() -> Template {
context.title = Some("Send Password Reset".to_string());
context.flash_name = Some("error".to_string());
context.flash_msg = Some(format!("Failed to send password reset link: {}", err));
Template::render("password/send_password_reset", &context)
Template::render("password/forgot_password", &context)
}
}
}

View File

@ -10,9 +10,9 @@
<input id="password" name="password" class="center input" type="password" placeholder="Password" title="Password for given username"/>
<div id="buttonDiv">
<input id="loginUser" class="button button-primary center" title="Login" type="submit" value="Login">
<a class="button button-secondary center" href="/" title="Cancel">Cancel</a>
</div>
</form>
<!-- FLASH MESSAGE -->
<!-- check for flash message and display accordingly -->
{% if flash_msg and flash_name == "success" %}
@ -25,6 +25,10 @@
<!-- display error message -->
<div class="capsule center-text flash-message font-failure">{{ flash_msg }}.</div>
{%- endif -%}
<div class="forgot-password center-text" style="margin-top: 50px;">
<a href="/forgot_password" style="text-decoration: none; color: gray;">Forgot Password?</a>
</div>
</div>
</div>