mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
refactor(templates): utilize more accurate naming (#3125)
This commit is contained in:
parent
4ebd8fdf4e
commit
06fd7105ea
|
@ -47,41 +47,46 @@ required: no
|
||||||
{: .label .label-config .label-green }
|
{: .label .label-config .label-green }
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
This option allows the administrator to set custom templates for notifications
|
This option allows the administrator to set a path where custom templates for notifications can be found. Each template
|
||||||
the templates folder should contain the following files
|
has two extensions; `.html` for HTML templates, and `.txt` for plaintext templates.
|
||||||
|
|
||||||
|File |Description |
|
| Template | Description |
|
||||||
|------------------------|---------------------------------------------------|
|
|:--------------------:|:-----------------------------------------------------------------------------------------------:|
|
||||||
|PasswordResetStep1.html |HTML Template for Step 1 of password reset process |
|
| IdentityVerification | Template used when registering devices or resetting passwords |
|
||||||
|PasswordResetStep1.txt |Text Template for Step 1 of password reset process |
|
| PasswordReset | Template used to send the notification to users when their password has successfully been reset |
|
||||||
|PasswordResetStep2.html |HTML Template for Step 2 of password reset process |
|
|
||||||
|PasswordResetStep2.txt |Text Template for Step 2 of password reset process |
|
|
||||||
|
|
||||||
Note:
|
For example, to modify the `IdentityVerification` HTML template, if your `template_path` was `/config/email_templates`,
|
||||||
* if you don't define some of these files, a default template is used for that notification
|
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:
|
In template files, you can use the following variables:
|
||||||
|
|
||||||
|File |Description |
|
| Placeholder | Templates | Description |
|
||||||
|------------------------|---------------------------------------------------|
|
|:--------------------:|:--------------------:|:---------------------------------------------------------------------------------------------------------------------------------------------:|
|
||||||
|`{{.title}}`| A predefined title for the email. <br> It will be `"Reset your password"` or `"Password changed successfully"`, depending on the current step |
|
| `{{ .LinkURL }}` | IdentityVerification | The URL of the used with the IdentityVerification template. |
|
||||||
|`{{.url}}` | The url that allows to reset the user password |
|
| `{{ .LinkText }}` | IdentityVerification | The display value for the IdentityVerification button intended for the link. |
|
||||||
|`{{.displayName}}` |The name of the user, i.e. `John Doe` |
|
| `{{ .Title }}` | All | A predefined title for the email. <br> It will be `"Reset your password"` or `"Password changed successfully"`, depending on the current step |
|
||||||
|`{{.button}}` |The content for the password reset button, it's hardcoded to `Reset` |
|
| `{{ .DisplayName }}` | All | The name of the user, i.e. `John Doe` |
|
||||||
|`{{.remoteIP}}` |The remote IP address that initiated the request or event |
|
| `{{ .RemoteIP }}` | All | The remote IP address that initiated the request or event |
|
||||||
|
|
||||||
#### Example
|
#### Examples
|
||||||
|
|
||||||
|
This is a basic example:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<body>
|
<body>
|
||||||
<h1>{{.title}}</h1>
|
<h1>{{ .Title }}</h1>
|
||||||
Hi {{.displayName}} <br/>
|
Hi {{ .DisplayName }}<br/>
|
||||||
This email has been sent to you in order to validate your identity
|
This email has been sent to you in order to validate your identity.
|
||||||
Click <a href="{{.url}}" >here</a> to change your password
|
Click <a href="{{ .LinkURL }}">here</a> to change your password.
|
||||||
</body>
|
</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
|
### filesystem
|
||||||
|
|
||||||
|
|
4
examples/templates/notifications/README.md
Normal file
4
examples/templates/notifications/README.md
Normal file
|
@ -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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if t, err = template.ParseFiles(filepath.Join(config.TemplatePath, templates.TemplateNameStep1+".html")); err == nil {
|
if t, err = template.ParseFiles(filepath.Join(config.TemplatePath, templates.TemplateNameIdentityVerification+".html")); err == nil {
|
||||||
templates.HTMLEmailTemplateStep1 = t
|
templates.EmailIdentityVerificationHTML = t
|
||||||
} else {
|
} 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 {
|
if t, err = template.ParseFiles(filepath.Join(config.TemplatePath, templates.TemplateNameIdentityVerification+".txt")); err == nil {
|
||||||
templates.PlainTextEmailTemplateStep1 = t
|
templates.EmailIdentityVerificationPlainText = t
|
||||||
} else {
|
} 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 {
|
if t, err = template.ParseFiles(filepath.Join(config.TemplatePath, templates.TemplateNameBasic+".html")); err == nil {
|
||||||
templates.HTMLEmailTemplateStep2 = t
|
templates.EmailPasswordResetHTML = t
|
||||||
} else {
|
} 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 {
|
if t, err = template.ParseFiles(filepath.Join(config.TemplatePath, templates.TemplateNameBasic+".txt")); err == nil {
|
||||||
templates.PlainTextEmailTemplateStep2 = t
|
templates.EmailPasswordResetPlainText = t
|
||||||
} else {
|
} 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 {
|
if !disableHTML {
|
||||||
htmlParams := map[string]interface{}{
|
htmlParams := map[string]interface{}{
|
||||||
"title": "Password changed successfully",
|
"Title": "Password changed successfully",
|
||||||
"displayName": userInfo.DisplayName,
|
"DisplayName": userInfo.DisplayName,
|
||||||
"remoteIP": ctx.RemoteIP().String(),
|
"RemoteIP": ctx.RemoteIP().String(),
|
||||||
}
|
}
|
||||||
|
|
||||||
err = templates.HTMLEmailTemplateStep2.Execute(bufHTML, htmlParams)
|
err = templates.EmailPasswordResetHTML.Execute(bufHTML, htmlParams)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Logger.Error(err)
|
ctx.Logger.Error(err)
|
||||||
|
@ -103,10 +103,10 @@ func ResetPasswordPost(ctx *middlewares.AutheliaCtx) {
|
||||||
|
|
||||||
bufText := new(bytes.Buffer)
|
bufText := new(bytes.Buffer)
|
||||||
textParams := map[string]interface{}{
|
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 {
|
if err != nil {
|
||||||
ctx.Logger.Error(err)
|
ctx.Logger.Error(err)
|
||||||
|
|
|
@ -79,14 +79,14 @@ func IdentityVerificationStart(args IdentityVerificationStartArgs, delayFunc Tim
|
||||||
|
|
||||||
if !disableHTML {
|
if !disableHTML {
|
||||||
htmlParams := map[string]interface{}{
|
htmlParams := map[string]interface{}{
|
||||||
"title": args.MailTitle,
|
"Title": args.MailTitle,
|
||||||
"url": link,
|
"LinkURL": link,
|
||||||
"button": args.MailButtonContent,
|
"LinkText": args.MailButtonContent,
|
||||||
"displayName": identity.DisplayName,
|
"DisplayName": identity.DisplayName,
|
||||||
"remoteIP": ctx.RemoteIP().String(),
|
"RemoteIP": ctx.RemoteIP().String(),
|
||||||
}
|
}
|
||||||
|
|
||||||
err = templates.HTMLEmailTemplateStep1.Execute(bufHTML, htmlParams)
|
err = templates.EmailIdentityVerificationHTML.Execute(bufHTML, htmlParams)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Error(err, messageOperationFailed)
|
ctx.Error(err, messageOperationFailed)
|
||||||
|
@ -96,11 +96,11 @@ func IdentityVerificationStart(args IdentityVerificationStartArgs, delayFunc Tim
|
||||||
|
|
||||||
bufText := new(bytes.Buffer)
|
bufText := new(bytes.Buffer)
|
||||||
textParams := map[string]interface{}{
|
textParams := map[string]interface{}{
|
||||||
"url": link,
|
"LinkURL": link,
|
||||||
"displayName": identity.DisplayName,
|
"DisplayName": identity.DisplayName,
|
||||||
}
|
}
|
||||||
|
|
||||||
err = templates.PlainTextEmailTemplateStep1.Execute(bufText, textParams)
|
err = templates.EmailIdentityVerificationPlainText.Execute(bufText, textParams)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Error(err, messageOperationFailed)
|
ctx.Error(err, messageOperationFailed)
|
||||||
|
|
|
@ -2,6 +2,6 @@ package templates
|
||||||
|
|
||||||
// Template File Names.
|
// Template File Names.
|
||||||
const (
|
const (
|
||||||
TemplateNameStep1 = "PasswordResetStep1"
|
TemplateNameBasic = "Basic"
|
||||||
TemplateNameStep2 = "PasswordResetStep2"
|
TemplateNameIdentityVerification = "IdentityVerification"
|
||||||
)
|
)
|
||||||
|
|
|
@ -4,19 +4,19 @@ import (
|
||||||
"text/template"
|
"text/template"
|
||||||
)
|
)
|
||||||
|
|
||||||
// HTMLEmailTemplateStep1 the template of email that the user will receive for identity verification.
|
// EmailIdentityVerificationHTML the template of email that the user will receive for identity verification.
|
||||||
var HTMLEmailTemplateStep1 *template.Template
|
var EmailIdentityVerificationHTML *template.Template
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
t, err := template.New("html_email_template").Parse(emailHTMLContentStep1)
|
t, err := template.New("email_identity_verification_html").Parse(emailContentIdentityVerificationHTML)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
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">
|
<!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">
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
|
||||||
|
@ -244,7 +244,7 @@ const emailHTMLContentStep1 = `
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="300" height="50" align="center">
|
<td width="300" height="50" align="center">
|
||||||
<h1>{{.title}}</h1>
|
<h1>{{ .Title }}</h1>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -317,7 +317,7 @@ const emailHTMLContentStep1 = `
|
||||||
<tr>
|
<tr>
|
||||||
<td style="font-family: Helvetica, arial, sans-serif; font-size: 16px; color: #333333; text-align:center; line-height: 30px;"
|
<td style="font-family: Helvetica, arial, sans-serif; font-size: 16px; color: #333333; text-align:center; line-height: 30px;"
|
||||||
st-title="fulltext-content">
|
st-title="fulltext-content">
|
||||||
Hi {{.displayName}}
|
Hi {{ .DisplayName }}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -339,19 +339,7 @@ const emailHTMLContentStep1 = `
|
||||||
<tr>
|
<tr>
|
||||||
<td style="font-family: Helvetica, arial, sans-serif; font-size: 16px; color: #666666; text-align:center; line-height: 30px;"
|
<td style="font-family: Helvetica, arial, sans-serif; font-size: 16px; color: #666666; text-align:center; line-height: 30px;"
|
||||||
st-content="fulltext-content">
|
st-content="fulltext-content">
|
||||||
<a href="{{.url}}" class="button">{{.button}}</a>
|
<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="{{.url}}" class="link">{{.url}}</a>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- End of content -->
|
<!-- End of content -->
|
||||||
|
@ -412,7 +400,7 @@ const emailHTMLContentStep1 = `
|
||||||
<td align="center" valign="middle"
|
<td align="center" valign="middle"
|
||||||
style="font-family: Helvetica, arial, sans-serif; font-size: 14px;color: #666666"
|
style="font-family: Helvetica, arial, sans-serif; font-size: 14px;color: #666666"
|
||||||
st-content="postfooter">
|
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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- spacing -->
|
<!-- spacing -->
|
||||||
|
@ -425,7 +413,7 @@ const emailHTMLContentStep1 = `
|
||||||
<tr>
|
<tr>
|
||||||
<td style="font-family: Helvetica, arial, sans-serif; font-style: italic; font-size: 12px; color: #333333; text-align:center; line-height: 30px;"
|
<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">
|
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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- Spacing -->
|
<!-- Spacing -->
|
28
internal/templates/email_identity_verification_plaintext.go
Normal file
28
internal/templates/email_identity_verification_plaintext.go
Normal file
|
@ -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"
|
"text/template"
|
||||||
)
|
)
|
||||||
|
|
||||||
// HTMLEmailTemplateStep2 the template of email that the user will receive for identity verification.
|
// EmailPasswordResetHTML the template of email that the user will receive for identity verification.
|
||||||
var HTMLEmailTemplateStep2 *template.Template
|
var EmailPasswordResetHTML *template.Template
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
t, err := template.New("html_email_template").Parse(emailHTMLContentStep2)
|
t, err := template.New("email_password_reset_html").Parse(emailContentPasswordResetHTML)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
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">
|
<!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">
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
|
||||||
|
@ -242,7 +243,7 @@ const emailHTMLContentStep2 = `
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="300" height="50" align="center">
|
<td width="300" height="50" align="center">
|
||||||
<h1>{{.title}}</h1>
|
<h1>{{ .Title }}</h1>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -315,7 +316,7 @@ const emailHTMLContentStep2 = `
|
||||||
<tr>
|
<tr>
|
||||||
<td style="font-family: Helvetica, arial, sans-serif; font-size: 16px; color: #333333; text-align:center; line-height: 30px;"
|
<td style="font-family: Helvetica, arial, sans-serif; font-size: 16px; color: #333333; text-align:center; line-height: 30px;"
|
||||||
st-title="fulltext-content">
|
st-title="fulltext-content">
|
||||||
Hi {{.displayName}} <br/>
|
Hi {{ .DisplayName }} <br/>
|
||||||
Your password has been successfully reset.
|
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.
|
If you did not initiate the process your credentials might have been compromised. You should reset your password and contact an administrator.
|
||||||
</td>
|
</td>
|
||||||
|
@ -385,7 +386,7 @@ const emailHTMLContentStep2 = `
|
||||||
<td align="center" valign="middle"
|
<td align="center" valign="middle"
|
||||||
style="font-family: Helvetica, arial, sans-serif; font-size: 14px;color: #666666"
|
style="font-family: Helvetica, arial, sans-serif; font-size: 14px;color: #666666"
|
||||||
st-content="postfooter">
|
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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- spacing -->
|
<!-- spacing -->
|
||||||
|
@ -398,7 +399,7 @@ const emailHTMLContentStep2 = `
|
||||||
<tr>
|
<tr>
|
||||||
<td style="font-family: Helvetica, arial, sans-serif; font-style: italic; font-size: 12px; color: #333333; text-align:center; line-height: 30px;"
|
<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">
|
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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- Spacing -->
|
<!-- Spacing -->
|
26
internal/templates/email_password_reset_plaintext.go
Normal file
26
internal/templates/email_password_reset_plaintext.go
Normal file
|
@ -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
Block a user