mirror of
https://github.com/lldap/lldap.git
synced 2026-03-31 15:07:48 +01:00
Include both display name and username in password reset emails
As requested by @nitnelave, the password reset email now includes both the display name for personalization and the username for recovery. The email uses the display name in the greeting when available, but always shows the username explicitly for recovery purposes. Co-authored-by: nitnelave <796633+nitnelave@users.noreply.github.com>
This commit is contained in:
@@ -186,6 +186,7 @@ where
|
|||||||
Some(token) => token,
|
Some(token) => token,
|
||||||
};
|
};
|
||||||
if let Err(e) = super::mail::send_password_reset_email(
|
if let Err(e) = super::mail::send_password_reset_email(
|
||||||
|
user.display_name.as_deref(),
|
||||||
user.user_id.as_str(),
|
user.user_id.as_str(),
|
||||||
user.email.as_str(),
|
user.email.as_str(),
|
||||||
&token,
|
&token,
|
||||||
|
|||||||
+8
-1
@@ -80,6 +80,7 @@ async fn send_email(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn send_password_reset_email(
|
pub async fn send_password_reset_email(
|
||||||
|
display_name: Option<&str>,
|
||||||
username: &str,
|
username: &str,
|
||||||
to: &str,
|
to: &str,
|
||||||
token: &str,
|
token: &str,
|
||||||
@@ -92,8 +93,14 @@ pub async fn send_password_reset_email(
|
|||||||
.path_segments_mut()
|
.path_segments_mut()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.extend(["reset-password", "step2", token]);
|
.extend(["reset-password", "step2", token]);
|
||||||
|
|
||||||
|
let greeting = match display_name {
|
||||||
|
Some(name) if !name.is_empty() => format!("Hello {name},"),
|
||||||
|
_ => "Hello,".to_string(),
|
||||||
|
};
|
||||||
|
|
||||||
let body = format!(
|
let body = format!(
|
||||||
"Hello,
|
"{greeting}
|
||||||
This email has been sent to you in order to validate your identity.
|
This email has been sent to you in order to validate your identity.
|
||||||
If you did not initiate the process your credentials might have been
|
If you did not initiate the process your credentials might have been
|
||||||
compromised. You should reset your password and contact an administrator.
|
compromised. You should reset your password and contact an administrator.
|
||||||
|
|||||||
Reference in New Issue
Block a user