email.templates: add configurable templates for setPassword, resetPassword#45671
Conversation
michaellzc
left a comment
There was a problem hiding this comment.
code lgtm
Growth should also review this and see if this meets their need as well
| Somebody (likely you) requested a password reset for the user {{.Username}} on Sourcegraph ({{.Host}}). | ||
|
|
||
| To reset the password for {{.Username}} on Sourcegraph, follow this link: | ||
|
|
||
| {{.URL}} | ||
| `, | ||
| HTML: ` | ||
| <p> | ||
| Somebody (likely you) requested a password reset for <strong>{{.Username}}</strong> | ||
| on Sourcegraph ({{.Host}}). | ||
| </p> | ||
|
|
||
| <p><strong><a href="{{.URL}}">Reset password for {{.Username}}</a></strong></p> | ||
| `, |
There was a problem hiding this comment.
Could we add a line in here that says something like:
If you did not request this password reset, please ignore this email and contact your Sourcegraph Cloud support representative.
There was a problem hiding this comment.
Note that:
- This email template existed before and is unchanged
- This email template must make sense for self-hosted instances, since this is the default
There was a problem hiding this comment.
Messaging like the above can be added to any custom email.templates we configure in Cloud once this feature is available in a Sourcegraph release (likely 4.4)
There was a problem hiding this comment.
Sounds good, I like that suggestion that we create a better template specific to Cloud!
| Text: ` | ||
| Somebody (likely you) requested a password reset for the user {{.Username}} on Sourcegraph ({{.Host}}). | ||
|
|
||
| To reset the password for {{.Username}} on Sourcegraph, follow this link: | ||
|
|
||
| {{.URL}} | ||
| `, | ||
| HTML: ` |
There was a problem hiding this comment.
In general, the content of both text and HTML versions are the same, is it on purpose that we don't want to automatically degrade HTML to text (i.e. removing all HTML elements)? If not, there is a package that can do that automatically: https://github.com/jaytaylor/html2text
There was a problem hiding this comment.
Good idea, I think removing HTML elements is a good default behaviour.
I ended up using a lighter version of the above library that is advertised in the README: https://github.com/sourcegraph/sourcegraph/pull/46085
This allows Cloud and Growth to customize emails sent to customers when creating users and resetting their passwords, which typically means customer side admins. The changes add:
email.templates, that allows us to add configurable templates for various emails that get sent outemail.templatesfields to ensure they are validCloses https://github.com/sourcegraph/customer/issues/1719
Test plan
Add a template:
Create a user in the admin UI:
Some simple unit tests were also added.
Also note that inline documentation is available about what each template accepts: