@@ -39,6 +39,7 @@ static EMAIL_MFA_CODE_EMAIL_SUBJECT: &str = "Your Multi-Factor Authentication Co
39
39
static GATEWAY_DISCONNECTED : & str = "Defguard: Gateway disconnected" ;
40
40
41
41
pub static EMAIL_PASSOWRD_RESET_START_SUBJECT : & str = "Defguard: Password reset" ;
42
+ pub static EMAIL_PASSOWRD_RESET_SUCCESS_SUBJECT : & str = "Defguard: Password reset success" ;
42
43
43
44
#[ derive( Clone , Deserialize ) ]
44
45
pub struct TestMail {
@@ -452,3 +453,33 @@ pub fn send_password_reset_email(
452
453
}
453
454
}
454
455
}
456
+
457
+ pub fn send_password_reset_success_email (
458
+ user : & User ,
459
+ mail_tx : & UnboundedSender < Mail > ,
460
+ ip_address : Option < String > ,
461
+ device_info : Option < String > ,
462
+ ) -> Result < ( ) , TokenError > {
463
+ debug ! ( "Sending password reset success email to {}" , user. email) ;
464
+
465
+ let mail = Mail {
466
+ to : user. email . clone ( ) ,
467
+ subject : EMAIL_PASSOWRD_RESET_SUCCESS_SUBJECT . into ( ) ,
468
+ content : templates:: email_password_reset_success_mail ( ip_address, device_info) ?,
469
+ attachments : Vec :: new ( ) ,
470
+ result_tx : None ,
471
+ } ;
472
+
473
+ let to = mail. to . clone ( ) ;
474
+
475
+ match mail_tx. send ( mail) {
476
+ Ok ( ( ) ) => {
477
+ info ! ( "Password reset email success sent to {to}" ) ;
478
+ Ok ( ( ) )
479
+ }
480
+ Err ( err) => {
481
+ error ! ( "Failed to send password reset success email to {to} with error:\n {err}" ) ;
482
+ Ok ( ( ) )
483
+ }
484
+ }
485
+ }
0 commit comments