Skip to content

Commit

Permalink
Refactor: Updated Email Template for Reset Password
Browse files Browse the repository at this point in the history
  • Loading branch information
jaymar921 committed Jan 10, 2024
1 parent 191985a commit 86a103f
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,61 @@ public EmailSenderService(IOptions<ApplicationSettings> appsettings)
_settings = appsettings.Value;
}

public void SendEmail(string email, string token)
public void SendEmail(string email, string firstname, string token)
{
MailMessage mailMessage = new MailMessage();
mailMessage.From = new MailAddress(_settings.SMTP_EMAIL, "🔎QuizMaster@no-reply", System.Text.Encoding.UTF8);
mailMessage.To.Add(email);
mailMessage.Subject = "Update Password like literal update";
mailMessage.Body = $"<html><body>Confirm Update password: <a href='https://localhost:7081/gateway/api/account/update_password/{token}'>Click to update</a></body></html>";
mailMessage.Subject = "Quiz Master Password Reset";
mailMessage.Body = @$"
<html><body>
<div style=""width: 400px"">
<img
style=""width: 400px; height: 84px""
src=""https://github.com/jaymar921/Public-Repo/blob/main/wave_fs_vector_1.png?raw=true""
/>
<h3 style=""text-align: center; color: #18a44c"">
Reset Password Confirmation
</h3>
<img
style=""width: 400px; height: 300px""
src=""https://github.com/jaymar921/Public-Repo/blob/main/reset_pass_fs.png?raw=true""
/>
<h3 style=""font-size: 18px; padding: 5px 20px 5px 20px"">Hello {firstname}</h3>
<p style=""font-size: 14px; padding: 5px 20px 5px 20px"">
You are receiving this email because you requested a change on your
password. Click the button below to reset your password.
</p>
<div style=""padding: 5px 20px 5px 20px; text-align: center"">
<a
style=""
background-color: #18a44c;
color: white;
padding: 10px;
font-size: 14px;
outline: none;
border: none;
border-radius: 4px;
width: 500px;
cursor: pointer;
text-decoration: none;
""
href='https://localhost:7081/gateway/api/account/update_password/{token}'
>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Confirm Reset
Password&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</a>
</div>
<p style=""padding: 0px 20px 0px 20px; font-size: 12px; color: gray"">
If you did not request a password reset, you can ignore this email.
</p>
<hr />
<p style=""padding: 0px 20px 0px 20px; font-size: 12px; color: gray"">
Copyright 2023 Ⓒ QuizMaster
</p>
</div>
</body></html>
";
mailMessage.IsBodyHtml = true;

// Create the credentials to login to the gmail account associated with my custom domain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ public override async Task<SetAccountAdminResponse> UpdateUserPassword(UpdatePas
}

string token = _passwordHandler.GenerateToken(request.Id.ToString(), request.CurrentPassword, request.NewPassword);
Task.Run(() => { _emailSenderService.SendEmail(existingUser.Email, token); });
Task.Run(() => { _emailSenderService.SendEmail(existingUser.Email, existingUser.FirstName, token); });

reply.Code = 200;
reply.Message = "A confirmation email was sent to your account.";
Expand Down

0 comments on commit 86a103f

Please sign in to comment.