Skip to content

Commit

Permalink
Replace email links with codes
Browse files Browse the repository at this point in the history
  • Loading branch information
turecross321 committed Sep 25, 2024
1 parent 8c6e470 commit 54d6c66
Showing 1 changed file with 15 additions and 20 deletions.
35 changes: 15 additions & 20 deletions SoundShapesServer.Common/EmailTemplates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,56 +4,51 @@ public static class EmailTemplates
{
public static string VerifyEmail(string userName, string instanceName, string websiteUrl, string verifyEmailCode, bool hasUserFinishedRegistration)
{
string verifyUrl = $"{websiteUrl}/verifyEmail?code={verifyEmailCode}";

string html = hasUserFinishedRegistration
? """
<html lang="en" style="font-size: 10pt; font-family: Tahoma, serif;">
<body style="color:#181515;">
<h1>Hello, {USER}</h1>
<h1>Hello, {{USER}}</h1>
<p>Please click the button below to verify your email address.</p>
<a href="{CODE_URL}" style="color: white; background-color: #F07167; padding: 0.5rem 1rem; border-radius: 0.5rem; font-size: x-large; text-decoration: none; display: inline-block;">Verify</a>
<strong style="color: white; background-color: #F07167; padding: 0.5rem 1rem; border-radius: 0.5rem; font-size: x-large; text-decoration: none; display: inline-block;">{{CODE}}</strong>
<p>If you didn't request this, please ignore this email.</p>
<p>Greetings, the {INSTANCE} team.</p>
<p>Greetings, the {{INSTANCE}} team.</p>
</body>
</html>
"""
: """
<html lang="en" style="font-size: 10pt; font-family: Tahoma, serif;">
<body style="color:#181515;">
<h1>Hello, {USER}</h1>
<h1>Hello, {{USER}}</h1>
<p>Please click the button below to verify your email address and finish the registration of your account.</p>
<a href="{CODE_URL}" style="color: white; background-color: #F07167; padding: 0.5rem 1rem; border-radius: 0.5rem; font-size: x-large; text-decoration: none; display: inline-block;">Verify</a>
<strong style="color: white; background-color: #F07167; padding: 0.5rem 1rem; border-radius: 0.5rem; font-size: x-large; text-decoration: none; display: inline-block;">{{CODE}}</strong>
<p>If you didn't request this, please ignore this email.</p>
<p>Greetings, the {INSTANCE} team.</p>
<p>Greetings, the {{INSTANCE}} team.</p>
</body>
</html>
""";

return html
.Replace("{USER}", userName)
.Replace("{INSTANCE}", instanceName)
.Replace("{CODE_URL}", verifyUrl);;
.Replace("{{USER}}", userName)
.Replace("{{INSTANCE}}", instanceName)
.Replace("{{CODE}}", verifyEmailCode);;
}

public static string PasswordReset(string userName, string instanceName, string websiteUrl, string resetPasswordCode)
{
string passwordUrl = $"{websiteUrl}/resetPassword?code={resetPasswordCode}";


return """
<html lang="en" style="font-size: 10pt; font-family: Tahoma, serif;">
<body style="color:#181515;">
<h1>Hello, {USER}</h1>
<h1>Hello, {{USER}}</h1>
<p>You may click the button below to reset your password.</p>
<a href="{CODE_URL}" style="color: white; background-color: #F07167; padding: 0.5rem 1rem; border-radius: 0.5rem; font-size: x-large; text-decoration: none; display: inline-block;">Reset Password</a>
<strong style="color: white; background-color: #F07167; padding: 0.5rem 1rem; border-radius: 0.5rem; font-size: x-large; text-decoration: none; display: inline-block;">{{CODE}}</strong>
<p>If you didn't request this, please ignore this email.</p>
<p>Greetings, the {INSTANCE} team.</p>
<p>Greetings, the {{INSTANCE}} team.</p>
</body>
</html>
"""
.Replace("{USER}", userName)
.Replace("{INSTANCE}", instanceName)
.Replace("{CODE_URL}", passwordUrl);
.Replace("{{USER}}", userName)
.Replace("{{INSTANCE}}", instanceName)
.Replace("{{CODE}}", resetPasswordCode);
}
}

0 comments on commit 54d6c66

Please sign in to comment.