Skip to content

Commit 41bf7d6

Browse files
committed
add missing name in MFA activated email
1 parent d025a2f commit 41bf7d6

5 files changed

Lines changed: 11 additions & 2 deletions

File tree

crates/defguard_core/src/handlers/auth.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,7 @@ pub async fn webauthn_finish(
496496
&mut conn,
497497
Some(&session.session.into()),
498498
&MFAMethod::Webauthn,
499+
&user.first_name,
499500
)
500501
.await?;
501502
user.set_mfa_method(&mut *conn, MFAMethod::Webauthn).await?;
@@ -658,6 +659,7 @@ pub async fn totp_enable(
658659
&mut conn,
659660
Some(&session.session.into()),
660661
&MFAMethod::OneTimePassword,
662+
&user.first_name,
661663
)
662664
.await?;
663665
user.set_mfa_method(&mut *conn, MFAMethod::OneTimePassword)
@@ -838,6 +840,7 @@ pub async fn email_mfa_enable(
838840
&mut conn,
839841
Some(&session.session.into()),
840842
&MFAMethod::Email,
843+
&user.first_name,
841844
)
842845
.await?;
843846
user.set_mfa_method(&mut *conn, MFAMethod::Email).await?;

crates/defguard_mail/src/templates.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,11 @@ pub async fn mfa_configured_mail(
393393
conn: &mut PgConnection,
394394
session: Option<&SessionContext>,
395395
method: &MFAMethod,
396+
first_name: &str,
396397
) -> Result<(), TemplateError> {
397398
let (mut tera, mut context) = get_base_tera_mjml(Context::new(), session, None, None)?;
398399

400+
context.insert("username", first_name);
399401
context.insert("mfa_method", &method);
400402

401403
let message = MailMessage::MFAConfigured { method: *method };

crates/defguard_mail/src/tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ fn send_mfa_configured_mail(_: PgPoolOptions, options: PgConnectOptions) {
258258
&mut conn,
259259
None,
260260
&MFAMethod::Email,
261+
"Test",
261262
)
262263
.await
263264
.unwrap();
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{ title }}
1+
{{ title }}{% if username %} {{ username }}{% endif %}
22
{% if subtitle %}{{ subtitle }}{% endif %}
33

44
{{ mfa_method_label }} {{ mfa_method }}

crates/defguard_proxy_manager/src/servers/enrollment.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,10 @@ impl EnrollmentServer {
10741074
.map_err(|_| Status::internal("Failed to get recovery codes.".to_string()))?
10751075
.ok_or_else(|| Status::internal("Recovery codes not found".to_string()))?;
10761076
if let Ok(mut conn) = self.pool.begin().await {
1077-
if let Err(err) = mfa_configured_mail(&user.email, &mut conn, None, &mfa_method).await {
1077+
if let Err(err) =
1078+
mfa_configured_mail(&user.email, &mut conn, None, &mfa_method, &user.first_name)
1079+
.await
1080+
{
10781081
error!("Failed to send MFA configured email\nReason: {err}");
10791082
}
10801083
} else {

0 commit comments

Comments
 (0)