refactor(templates): utilize more accurate naming (#3125)
parent
4ebd8fdf4e
commit
06fd7105ea
|
@ -47,41 +47,46 @@ required: no
|
|||
{: .label .label-config .label-green }
|
||||
</div>
|
||||
|
||||
This option allows the administrator to set custom templates for notifications
|
||||
the templates folder should contain the following files
|
||||
This option allows the administrator to set a path where custom templates for notifications can be found. Each template
|
||||
has two extensions; `.html` for HTML templates, and `.txt` for plaintext templates.
|
||||
|
||||
|File |Description |
|
||||
|------------------------|---------------------------------------------------|
|
||||
|PasswordResetStep1.html |HTML Template for Step 1 of password reset process |
|
||||
|PasswordResetStep1.txt |Text Template for Step 1 of password reset process |
|
||||
|PasswordResetStep2.html |HTML Template for Step 2 of password reset process |
|
||||
|PasswordResetStep2.txt |Text Template for Step 2 of password reset process |
|
||||
| Template | Description |
|
||||
|:--------------------:|:-----------------------------------------------------------------------------------------------:|
|
||||
| IdentityVerification | Template used when registering devices or resetting passwords |
|
||||
| PasswordReset | Template used to send the notification to users when their password has successfully been reset |
|
||||
|
||||
Note:
|
||||
* if you don't define some of these files, a default template is used for that notification
|
||||
For example, to modify the `IdentityVerification` HTML template, if your `template_path` was `/config/email_templates`,
|
||||
you would create the `/config/email_templates/IdentityVerification.html` file.
|
||||
|
||||
_**Note:** you may configure this directory and add only add the templates you wish to override, any templates not
|
||||
supplied in this folder will utilize the default templates._
|
||||
|
||||
|
||||
In template files, you can use the following variables:
|
||||
|
||||
|File |Description |
|
||||
|------------------------|---------------------------------------------------|
|
||||
|`{{.title}}`| A predefined title for the email. <br> It will be `"Reset your password"` or `"Password changed successfully"`, depending on the current step |
|
||||
|`{{.url}}` | The url that allows to reset the user password |
|
||||
|`{{.displayName}}` |The name of the user, i.e. `John Doe` |
|
||||
|`{{.button}}` |The content for the password reset button, it's hardcoded to `Reset` |
|
||||
|`{{.remoteIP}}` |The remote IP address that initiated the request or event |
|
||||
| Placeholder | Templates | Description |
|
||||
|:--------------------:|:--------------------:|:---------------------------------------------------------------------------------------------------------------------------------------------:|
|
||||
| `{{ .LinkURL }}` | IdentityVerification | The URL of the used with the IdentityVerification template. |
|
||||
| `{{ .LinkText }}` | IdentityVerification | The display value for the IdentityVerification button intended for the link. |
|
||||
| `{{ .Title }}` | All | A predefined title for the email. <br> It will be `"Reset your password"` or `"Password changed successfully"`, depending on the current step |
|
||||
| `{{ .DisplayName }}` | All | The name of the user, i.e. `John Doe` |
|
||||
| `{{ .RemoteIP }}` | All | The remote IP address that initiated the request or event |
|
||||
|
||||
#### Example
|
||||
#### Examples
|
||||
|
||||
This is a basic example:
|
||||
|
||||
```html
|
||||
<body>
|
||||
<h1>{{.title}}</h1>
|
||||
Hi {{.displayName}} <br/>
|
||||
This email has been sent to you in order to validate your identity
|
||||
Click <a href="{{.url}}" >here</a> to change your password
|
||||
<h1>{{ .Title }}</h1>
|
||||
Hi {{ .DisplayName }}<br/>
|
||||
This email has been sent to you in order to validate your identity.
|
||||
Click <a href="{{ .LinkURL }}">here</a> to change your password.
|
||||
</body>
|
||||
```
|
||||
|
||||
Some Additional examples for specific purposes can be found in the
|
||||
[examples directory on GitHub](https://github.com/authelia/authelia/tree/master/examples/templates/notifications).
|
||||
|
||||
### filesystem
|
||||
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
# Notification Templates
|
||||
|
||||
The following folder contains email templates as examples of what can be done with the email template system. See the
|
||||
[docs](https://www.authelia.com/docs/configuration/notifier/#template_path) for more information.
|
|
@ -0,0 +1,430 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Authelia</title>
|
||||
|
||||
<style type="text/css">
|
||||
/* client-specific Styles */
|
||||
#outlook a {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* Force Outlook to provide a "view in browser" menu link. */
|
||||
body {
|
||||
width: 100% !important;
|
||||
-webkit-text-size-adjust: 100%;
|
||||
-ms-text-size-adjust: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* Prevent Webkit and Windows Mobile platforms from changing default font sizes, while not breaking desktop design. */
|
||||
.ExternalClass {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* Force Hotmail to display emails at full width */
|
||||
.ExternalClass,
|
||||
.ExternalClass p,
|
||||
.ExternalClass span,
|
||||
.ExternalClass font,
|
||||
.ExternalClass td,
|
||||
.ExternalClass div {
|
||||
line-height: 100%;
|
||||
}
|
||||
|
||||
/* Force Hotmail to display normal line spacing.*/
|
||||
#backgroundTable {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100% !important;
|
||||
line-height: 100% !important;
|
||||
}
|
||||
|
||||
img {
|
||||
outline: none;
|
||||
text-decoration: none;
|
||||
border: none;
|
||||
-ms-interpolation-mode: bicubic;
|
||||
}
|
||||
|
||||
a img {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.image_fix {
|
||||
display: block;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0px 0px !important;
|
||||
}
|
||||
|
||||
table td {
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
mso-table-lspace: 0pt;
|
||||
mso-table-rspace: 0pt;
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
text-decoration: none !important;
|
||||
}
|
||||
|
||||
h1 {
|
||||
line-height: 30px;
|
||||
}
|
||||
|
||||
.button {
|
||||
color: #ffffff;
|
||||
padding: 15px 30px;
|
||||
border-radius: 10px;
|
||||
background: rgb(25, 118, 210);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.link {
|
||||
color: rgb(25, 118, 210);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
|
||||
/*STYLES*/
|
||||
table[class=full] {
|
||||
width: 100%;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
/*IPAD STYLES*/
|
||||
@media only screen and (max-width: 640px) {
|
||||
|
||||
a[href^="tel"],
|
||||
a[href^="sms"] {
|
||||
text-decoration: none;
|
||||
color: #0a8cce;
|
||||
/* or whatever your want */
|
||||
pointer-events: none;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.mobile_link a[href^="tel"],
|
||||
.mobile_link a[href^="sms"] {
|
||||
text-decoration: default;
|
||||
color: #0a8cce !important;
|
||||
pointer-events: auto;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
table[class=devicewidth] {
|
||||
width: 440px !important;
|
||||
text-align: center !important;
|
||||
}
|
||||
|
||||
table[class=devicewidthinner] {
|
||||
width: 420px !important;
|
||||
text-align: center !important;
|
||||
}
|
||||
|
||||
img[class=banner] {
|
||||
width: 440px !important;
|
||||
height: 220px !important;
|
||||
}
|
||||
|
||||
img[class=colimg2] {
|
||||
width: 440px !important;
|
||||
height: 220px !important;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*IPHONE STYLES*/
|
||||
@media only screen and (max-width: 480px) {
|
||||
|
||||
a[href^="tel"],
|
||||
a[href^="sms"] {
|
||||
text-decoration: none;
|
||||
color: #0a8cce;
|
||||
/* or whatever your want */
|
||||
pointer-events: none;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.mobile_link a[href^="tel"],
|
||||
.mobile_link a[href^="sms"] {
|
||||
text-decoration: default;
|
||||
color: #0a8cce !important;
|
||||
pointer-events: auto;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
table[class=devicewidth] {
|
||||
width: 280px !important;
|
||||
text-align: center !important;
|
||||
}
|
||||
|
||||
table[class=devicewidthinner] {
|
||||
width: 260px !important;
|
||||
text-align: center !important;
|
||||
}
|
||||
|
||||
img[class=banner] {
|
||||
width: 280px !important;
|
||||
height: 140px !important;
|
||||
}
|
||||
|
||||
img[class=colimg2] {
|
||||
width: 280px !important;
|
||||
height: 140px !important;
|
||||
}
|
||||
|
||||
td[class=mobile-hide] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
td[class="padding-bottom25"] {
|
||||
padding-bottom: 25px !important;
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- Start of header -->
|
||||
<table width="100%" bgcolor="#ffffff" cellpadding="0" cellspacing="0" border="0" id="backgroundTable"
|
||||
st-sortable="header">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<table width="600" cellpadding="0" cellspacing="0" border="0" align="center" class="devicewidth">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td width="100%">
|
||||
<table width="600" cellpadding="0" cellspacing="0" border="0" align="center"
|
||||
class="devicewidth">
|
||||
<tbody>
|
||||
<!-- Spacing -->
|
||||
<tr>
|
||||
<td height="20"
|
||||
style="font-size:1px; line-height:1px; mso-line-height-rule: exactly;">
|
||||
</td>
|
||||
</tr>
|
||||
<!-- Spacing -->
|
||||
<tr>
|
||||
<td>
|
||||
<!-- logo -->
|
||||
<table width="140" align="center" border="0" cellpadding="0" cellspacing="0"
|
||||
class="devicewidth">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td width="300" height="50" align="center">
|
||||
<h1>{{ .Title }}</h1>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<!-- end of logo -->
|
||||
</td>
|
||||
</tr>
|
||||
<!-- Spacing -->
|
||||
<tr>
|
||||
<td height="20"
|
||||
style="font-size:1px; line-height:1px; mso-line-height-rule: exactly;">
|
||||
</td>
|
||||
</tr>
|
||||
<!-- Spacing -->
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<!-- End of Header -->
|
||||
<!-- Start of separator -->
|
||||
<table width="100%" bgcolor="#ffffff" cellpadding="0" cellspacing="0" border="0" id="backgroundTable"
|
||||
st-sortable="separator">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<table width="600" align="center" cellspacing="0" cellpadding="0" border="0" class="devicewidth">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td align="center" height="20" style="font-size:1px; line-height:1px;"> </td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<!-- End of separator -->
|
||||
<!-- Start Full Text -->
|
||||
<table width="100%" bgcolor="#ffffff" cellpadding="0" cellspacing="0" border="0" id="backgroundTable"
|
||||
st-sortable="full-text">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<table width="600" cellpadding="0" cellspacing="0" border="0" align="center" class="devicewidth">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td width="100%">
|
||||
<table width="600" cellpadding="0" cellspacing="0" border="0" align="center"
|
||||
class="devicewidth">
|
||||
<tbody>
|
||||
<!-- Spacing -->
|
||||
<tr>
|
||||
<td height="20"
|
||||
style="font-size:1px; line-height:1px; mso-line-height-rule: exactly;">
|
||||
</td>
|
||||
</tr>
|
||||
<!-- Spacing -->
|
||||
<tr>
|
||||
<td>
|
||||
<table width="560" align="center" cellpadding="0" cellspacing="0" border="0"
|
||||
class="devicewidthinner">
|
||||
<tbody>
|
||||
<!-- Title -->
|
||||
<tr>
|
||||
<td style="font-family: Helvetica, arial, sans-serif; font-size: 16px; color: #333333; text-align:center; line-height: 30px;"
|
||||
st-title="fulltext-content">
|
||||
Hi {{ .DisplayName }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="font-family: Helvetica, arial, sans-serif; font-size: 16px; color: #333333; text-align:center; line-height: 30px;"
|
||||
st-title="fulltext-content">
|
||||
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 compromised. You should reset your password and contact an administrator.
|
||||
</td>
|
||||
</tr>
|
||||
<!-- End of Title -->
|
||||
<!-- spacing -->
|
||||
<tr>
|
||||
<td width="100%" height="20"
|
||||
style="font-size:1px; line-height:1px; mso-line-height-rule: exactly;">
|
||||
</td>
|
||||
</tr>
|
||||
<!-- End of spacing -->
|
||||
<!-- content -->
|
||||
<tr>
|
||||
<td style="font-family: Helvetica, arial, sans-serif; font-size: 16px; color: #666666; text-align:center; line-height: 30px;"
|
||||
st-content="fulltext-content">
|
||||
<a href="{{ .LinkURL }}" class="button">{{ .LinkText }}</a>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- spacing -->
|
||||
<tr>
|
||||
<td width="100%" height="20"
|
||||
style="font-size:1px; line-height:1px; mso-line-height-rule: exactly;">
|
||||
</td>
|
||||
</tr>
|
||||
<!-- End of spacing -->
|
||||
<tr>
|
||||
<td style="word-break: break-word; overflow-wrap: break-word; text-align:center; line-height: 30px;">
|
||||
<a href="{{ .LinkURL }}" class="link">{{ .LinkURL }}</a>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- End of content -->
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<!-- end of full text -->
|
||||
<!-- Start of separator -->
|
||||
<table width="100%" bgcolor="#ffffff" cellpadding="0" cellspacing="0" border="0" id="backgroundTable"
|
||||
st-sortable="separator">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<table width="600" align="center" cellspacing="0" cellpadding="0" border="0" class="devicewidth">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td align="center" height="30" style="font-size:1px; line-height:1px;"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="550" align="center" height="1" bgcolor="#d1d1d1"
|
||||
style="font-size:1px; line-height:1px;"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center" height="30" style="font-size:1px; line-height:1px;"> </td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<!-- End of separator -->
|
||||
<!-- Start of Postfooter -->
|
||||
<table width="100%" bgcolor="#ffffff" cellpadding="0" cellspacing="0" border="0" id="backgroundTable"
|
||||
st-sortable="postfooter">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<table width="600" cellpadding="0" cellspacing="0" border="0" align="center" class="devicewidth">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td width="100%">
|
||||
<table width="600" cellpadding="0" cellspacing="0" border="0" align="center"
|
||||
class="devicewidth">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td align="center" valign="middle"
|
||||
style="font-family: Helvetica, arial, sans-serif; font-size: 14px;color: #666666"
|
||||
st-content="postfooter">
|
||||
Please contact an administrator if you did not initiate this process.
|
||||
</td>
|
||||
</tr>
|
||||
<!-- spacing -->
|
||||
<tr>
|
||||
<td width="100%" height="20"
|
||||
style="font-size:1px; line-height:1px; mso-line-height-rule: exactly;">
|
||||
</td>
|
||||
</tr>
|
||||
<!-- End of spacing -->
|
||||
<tr>
|
||||
<td style="font-family: Helvetica, arial, sans-serif; font-style: italic; font-size: 12px; color: #333333; text-align:center; line-height: 30px;"
|
||||
st-title="fulltext-content">
|
||||
This email was generated by a request from the IP address {{ .RemoteIP }}.
|
||||
</td>
|
||||
</tr>
|
||||
<!-- Spacing -->
|
||||
<tr>
|
||||
<td width="100%" height="20"></td>
|
||||
</tr>
|
||||
<!-- Spacing -->
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<!-- End of postfooter -->
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -56,28 +56,28 @@ func validateNotifierTemplates(config *schema.NotifierConfiguration, validator *
|
|||
return
|
||||
}
|
||||
|
||||
if t, err = template.ParseFiles(filepath.Join(config.TemplatePath, templates.TemplateNameStep1+".html")); err == nil {
|
||||
templates.HTMLEmailTemplateStep1 = t
|
||||
if t, err = template.ParseFiles(filepath.Join(config.TemplatePath, templates.TemplateNameIdentityVerification+".html")); err == nil {
|
||||
templates.EmailIdentityVerificationHTML = t
|
||||
} else {
|
||||
validator.PushWarning(fmt.Errorf(errFmtNotifierTemplateLoad, templates.TemplateNameStep1+".html", err))
|
||||
validator.PushWarning(fmt.Errorf(errFmtNotifierTemplateLoad, templates.TemplateNameIdentityVerification+".html", err))
|
||||
}
|
||||
|
||||
if t, err = template.ParseFiles(filepath.Join(config.TemplatePath, templates.TemplateNameStep1+".txt")); err == nil {
|
||||
templates.PlainTextEmailTemplateStep1 = t
|
||||
if t, err = template.ParseFiles(filepath.Join(config.TemplatePath, templates.TemplateNameIdentityVerification+".txt")); err == nil {
|
||||
templates.EmailIdentityVerificationPlainText = t
|
||||
} else {
|
||||
validator.PushWarning(fmt.Errorf(errFmtNotifierTemplateLoad, templates.TemplateNameStep1+".txt", err))
|
||||
validator.PushWarning(fmt.Errorf(errFmtNotifierTemplateLoad, templates.TemplateNameIdentityVerification+".txt", err))
|
||||
}
|
||||
|
||||
if t, err = template.ParseFiles(filepath.Join(config.TemplatePath, templates.TemplateNameStep2+".html")); err == nil {
|
||||
templates.HTMLEmailTemplateStep2 = t
|
||||
if t, err = template.ParseFiles(filepath.Join(config.TemplatePath, templates.TemplateNameBasic+".html")); err == nil {
|
||||
templates.EmailPasswordResetHTML = t
|
||||
} else {
|
||||
validator.PushWarning(fmt.Errorf(errFmtNotifierTemplateLoad, templates.TemplateNameStep2+".html", err))
|
||||
validator.PushWarning(fmt.Errorf(errFmtNotifierTemplateLoad, templates.TemplateNameBasic+".html", err))
|
||||
}
|
||||
|
||||
if t, err = template.ParseFiles(filepath.Join(config.TemplatePath, templates.TemplateNameStep2+".txt")); err == nil {
|
||||
templates.PlainTextEmailTemplateStep2 = t
|
||||
if t, err = template.ParseFiles(filepath.Join(config.TemplatePath, templates.TemplateNameBasic+".txt")); err == nil {
|
||||
templates.EmailPasswordResetPlainText = t
|
||||
} else {
|
||||
validator.PushWarning(fmt.Errorf(errFmtNotifierTemplateLoad, templates.TemplateNameStep2+".txt", err))
|
||||
validator.PushWarning(fmt.Errorf(errFmtNotifierTemplateLoad, templates.TemplateNameBasic+".txt", err))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -86,12 +86,12 @@ func ResetPasswordPost(ctx *middlewares.AutheliaCtx) {
|
|||
|
||||
if !disableHTML {
|
||||
htmlParams := map[string]interface{}{
|
||||
"title": "Password changed successfully",
|
||||
"displayName": userInfo.DisplayName,
|
||||
"remoteIP": ctx.RemoteIP().String(),
|
||||
"Title": "Password changed successfully",
|
||||
"DisplayName": userInfo.DisplayName,
|
||||
"RemoteIP": ctx.RemoteIP().String(),
|
||||
}
|
||||
|
||||
err = templates.HTMLEmailTemplateStep2.Execute(bufHTML, htmlParams)
|
||||
err = templates.EmailPasswordResetHTML.Execute(bufHTML, htmlParams)
|
||||
|
||||
if err != nil {
|
||||
ctx.Logger.Error(err)
|
||||
|
@ -103,10 +103,10 @@ func ResetPasswordPost(ctx *middlewares.AutheliaCtx) {
|
|||
|
||||
bufText := new(bytes.Buffer)
|
||||
textParams := map[string]interface{}{
|
||||
"displayName": userInfo.DisplayName,
|
||||
"DisplayName": userInfo.DisplayName,
|
||||
}
|
||||
|
||||
err = templates.PlainTextEmailTemplateStep2.Execute(bufText, textParams)
|
||||
err = templates.EmailPasswordResetPlainText.Execute(bufText, textParams)
|
||||
|
||||
if err != nil {
|
||||
ctx.Logger.Error(err)
|
||||
|
|
|
@ -79,14 +79,14 @@ func IdentityVerificationStart(args IdentityVerificationStartArgs, delayFunc Tim
|
|||
|
||||
if !disableHTML {
|
||||
htmlParams := map[string]interface{}{
|
||||
"title": args.MailTitle,
|
||||
"url": link,
|
||||
"button": args.MailButtonContent,
|
||||
"displayName": identity.DisplayName,
|
||||
"remoteIP": ctx.RemoteIP().String(),
|
||||
"Title": args.MailTitle,
|
||||
"LinkURL": link,
|
||||
"LinkText": args.MailButtonContent,
|
||||
"DisplayName": identity.DisplayName,
|
||||
"RemoteIP": ctx.RemoteIP().String(),
|
||||
}
|
||||
|
||||
err = templates.HTMLEmailTemplateStep1.Execute(bufHTML, htmlParams)
|
||||
err = templates.EmailIdentityVerificationHTML.Execute(bufHTML, htmlParams)
|
||||
|
||||
if err != nil {
|
||||
ctx.Error(err, messageOperationFailed)
|
||||
|
@ -96,11 +96,11 @@ func IdentityVerificationStart(args IdentityVerificationStartArgs, delayFunc Tim
|
|||
|
||||
bufText := new(bytes.Buffer)
|
||||
textParams := map[string]interface{}{
|
||||
"url": link,
|
||||
"displayName": identity.DisplayName,
|
||||
"LinkURL": link,
|
||||
"DisplayName": identity.DisplayName,
|
||||
}
|
||||
|
||||
err = templates.PlainTextEmailTemplateStep1.Execute(bufText, textParams)
|
||||
err = templates.EmailIdentityVerificationPlainText.Execute(bufText, textParams)
|
||||
|
||||
if err != nil {
|
||||
ctx.Error(err, messageOperationFailed)
|
||||
|
|
|
@ -2,6 +2,6 @@ package templates
|
|||
|
||||
// Template File Names.
|
||||
const (
|
||||
TemplateNameStep1 = "PasswordResetStep1"
|
||||
TemplateNameStep2 = "PasswordResetStep2"
|
||||
TemplateNameBasic = "Basic"
|
||||
TemplateNameIdentityVerification = "IdentityVerification"
|
||||
)
|
||||
|
|
|
@ -4,19 +4,19 @@ import (
|
|||
"text/template"
|
||||
)
|
||||
|
||||
// HTMLEmailTemplateStep1 the template of email that the user will receive for identity verification.
|
||||
var HTMLEmailTemplateStep1 *template.Template
|
||||
// EmailIdentityVerificationHTML the template of email that the user will receive for identity verification.
|
||||
var EmailIdentityVerificationHTML *template.Template
|
||||
|
||||
func init() {
|
||||
t, err := template.New("html_email_template").Parse(emailHTMLContentStep1)
|
||||
t, err := template.New("email_identity_verification_html").Parse(emailContentIdentityVerificationHTML)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
HTMLEmailTemplateStep1 = t
|
||||
EmailIdentityVerificationHTML = t
|
||||
}
|
||||
|
||||
const emailHTMLContentStep1 = `
|
||||
const emailContentIdentityVerificationHTML = `
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
|
||||
|
@ -244,7 +244,7 @@ const emailHTMLContentStep1 = `
|
|||
<tbody>
|
||||
<tr>
|
||||
<td width="300" height="50" align="center">
|
||||
<h1>{{.title}}</h1>
|
||||
<h1>{{ .Title }}</h1>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
@ -317,7 +317,7 @@ const emailHTMLContentStep1 = `
|
|||
<tr>
|
||||
<td style="font-family: Helvetica, arial, sans-serif; font-size: 16px; color: #333333; text-align:center; line-height: 30px;"
|
||||
st-title="fulltext-content">
|
||||
Hi {{.displayName}}
|
||||
Hi {{ .DisplayName }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -339,19 +339,7 @@ const emailHTMLContentStep1 = `
|
|||
<tr>
|
||||
<td style="font-family: Helvetica, arial, sans-serif; font-size: 16px; color: #666666; text-align:center; line-height: 30px;"
|
||||
st-content="fulltext-content">
|
||||
<a href="{{.url}}" class="button">{{.button}}</a>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- spacing -->
|
||||
<tr>
|
||||
<td width="100%" height="20"
|
||||
style="font-size:1px; line-height:1px; mso-line-height-rule: exactly;">
|
||||
</td>
|
||||
</tr>
|
||||
<!-- End of spacing -->
|
||||
<tr>
|
||||
<td style="word-break: break-word; overflow-wrap: break-word; text-align:center; line-height: 30px;">
|
||||
<a href="{{.url}}" class="link">{{.url}}</a>
|
||||
<a href="{{ .LinkURL }}" class="button">{{ .LinkText }}</a>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- End of content -->
|
||||
|
@ -412,7 +400,7 @@ const emailHTMLContentStep1 = `
|
|||
<td align="center" valign="middle"
|
||||
style="font-family: Helvetica, arial, sans-serif; font-size: 14px;color: #666666"
|
||||
st-content="postfooter">
|
||||
Please contact an administrator if you did not initiate the process.
|
||||
Please contact an administrator if you did not initiate this process.
|
||||
</td>
|
||||
</tr>
|
||||
<!-- spacing -->
|
||||
|
@ -425,7 +413,7 @@ const emailHTMLContentStep1 = `
|
|||
<tr>
|
||||
<td style="font-family: Helvetica, arial, sans-serif; font-style: italic; font-size: 12px; color: #333333; text-align:center; line-height: 30px;"
|
||||
st-title="fulltext-content">
|
||||
This email was generated by some with the IP address {{.remoteIP}}.
|
||||
This email was generated by a request from the IP address {{ .RemoteIP }}.
|
||||
</td>
|
||||
</tr>
|
||||
<!-- Spacing -->
|
|
@ -0,0 +1,28 @@
|
|||
package templates
|
||||
|
||||
import (
|
||||
"text/template"
|
||||
)
|
||||
|
||||
// EmailIdentityVerificationPlainText the template of email that the user will receive for identity verification.
|
||||
var EmailIdentityVerificationPlainText *template.Template
|
||||
|
||||
func init() {
|
||||
t, err := template.New("email_identity_verification_plain_text").Parse(emailContentIdentityVerificationPlainText)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
EmailIdentityVerificationPlainText = t
|
||||
}
|
||||
|
||||
const emailContentIdentityVerificationPlainText = `
|
||||
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 compromised. You should reset your password and contact an administrator.
|
||||
|
||||
To setup your 2FA please visit the following URL: {{ .LinkURL }}
|
||||
|
||||
This email was generated by a user with the IP {{ .RemoteIP }}.
|
||||
|
||||
Please contact an administrator if you did not initiate this process.
|
||||
`
|
|
@ -4,19 +4,20 @@ import (
|
|||
"text/template"
|
||||
)
|
||||
|
||||
// HTMLEmailTemplateStep2 the template of email that the user will receive for identity verification.
|
||||
var HTMLEmailTemplateStep2 *template.Template
|
||||
// EmailPasswordResetHTML the template of email that the user will receive for identity verification.
|
||||
var EmailPasswordResetHTML *template.Template
|
||||
|
||||
func init() {
|
||||
t, err := template.New("html_email_template").Parse(emailHTMLContentStep2)
|
||||
t, err := template.New("email_password_reset_html").Parse(emailContentPasswordResetHTML)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
HTMLEmailTemplateStep2 = t
|
||||
EmailPasswordResetHTML = t
|
||||
}
|
||||
|
||||
const emailHTMLContentStep2 = `
|
||||
//nolint:gosec // This is a template not hardcoded credentials.
|
||||
const emailContentPasswordResetHTML = `
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
|
||||
|
@ -242,7 +243,7 @@ const emailHTMLContentStep2 = `
|
|||
<tbody>
|
||||
<tr>
|
||||
<td width="300" height="50" align="center">
|
||||
<h1>{{.title}}</h1>
|
||||
<h1>{{ .Title }}</h1>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
@ -315,7 +316,7 @@ const emailHTMLContentStep2 = `
|
|||
<tr>
|
||||
<td style="font-family: Helvetica, arial, sans-serif; font-size: 16px; color: #333333; text-align:center; line-height: 30px;"
|
||||
st-title="fulltext-content">
|
||||
Hi {{.displayName}} <br/>
|
||||
Hi {{ .DisplayName }} <br/>
|
||||
Your password has been successfully reset.
|
||||
If you did not initiate the process your credentials might have been compromised. You should reset your password and contact an administrator.
|
||||
</td>
|
||||
|
@ -385,7 +386,7 @@ const emailHTMLContentStep2 = `
|
|||
<td align="center" valign="middle"
|
||||
style="font-family: Helvetica, arial, sans-serif; font-size: 14px;color: #666666"
|
||||
st-content="postfooter">
|
||||
Please contact an administrator if you did not initiate the process.
|
||||
Please contact an administrator if you did not initiate this process.
|
||||
</td>
|
||||
</tr>
|
||||
<!-- spacing -->
|
||||
|
@ -398,7 +399,7 @@ const emailHTMLContentStep2 = `
|
|||
<tr>
|
||||
<td style="font-family: Helvetica, arial, sans-serif; font-style: italic; font-size: 12px; color: #333333; text-align:center; line-height: 30px;"
|
||||
st-title="fulltext-content">
|
||||
This email was generated by some with the IP address {{.remoteIP}}.
|
||||
This email was generated by a request from the IP address {{ .RemoteIP }}.
|
||||
</td>
|
||||
</tr>
|
||||
<!-- Spacing -->
|
|
@ -0,0 +1,26 @@
|
|||
package templates
|
||||
|
||||
import (
|
||||
"text/template"
|
||||
)
|
||||
|
||||
// EmailPasswordResetPlainText the template of email that the user will receive for identity verification.
|
||||
var EmailPasswordResetPlainText *template.Template
|
||||
|
||||
func init() {
|
||||
t, err := template.New("email_password_reset_plain_text").Parse(emailContentBasicPlainText)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
EmailPasswordResetPlainText = t
|
||||
}
|
||||
|
||||
const emailContentBasicPlainText = `
|
||||
Your password has been successfully reset.
|
||||
If you did not initiate the process your credentials might have been compromised. You should reset your password and contact an administrator.
|
||||
|
||||
This email was generated by a user with the IP {{ .RemoteIP }}.
|
||||
|
||||
Please contact an administrator if you did not initiate this process.
|
||||
`
|
|
@ -1,28 +0,0 @@
|
|||
package templates
|
||||
|
||||
import (
|
||||
"text/template"
|
||||
)
|
||||
|
||||
// PlainTextEmailTemplateStep1 the template of email that the user will receive for identity verification.
|
||||
var PlainTextEmailTemplateStep1 *template.Template
|
||||
|
||||
func init() {
|
||||
t, err := template.New("text_email_template").Parse(emailPlainTextContentStep1)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
PlainTextEmailTemplateStep1 = t
|
||||
}
|
||||
|
||||
const emailPlainTextContentStep1 = `
|
||||
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 compromised. You should reset your password and contact an administrator.
|
||||
|
||||
To setup your 2FA please visit the following URL: {{.url}}
|
||||
|
||||
This email was generated by a user with the IP {{.remoteIP}}.
|
||||
|
||||
Please contact an administrator if you did not initiate the process.
|
||||
`
|
|
@ -1,26 +0,0 @@
|
|||
package templates
|
||||
|
||||
import (
|
||||
"text/template"
|
||||
)
|
||||
|
||||
// PlainTextEmailTemplateStep2 the template of email that the user will receive for identity verification.
|
||||
var PlainTextEmailTemplateStep2 *template.Template
|
||||
|
||||
func init() {
|
||||
t, err := template.New("text_email_template").Parse(emailPlainTextContentStep2)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
PlainTextEmailTemplateStep2 = t
|
||||
}
|
||||
|
||||
const emailPlainTextContentStep2 = `
|
||||
Your password has been successfully reset.
|
||||
If you did not initiate the process your credentials might have been compromised. You should reset your password and contact an administrator.
|
||||
|
||||
This email was generated by a user with the IP {{.remoteIP}}.
|
||||
|
||||
Please contact an administrator if you did not initiate the process.
|
||||
`
|
Loading…
Reference in New Issue