Skip to content

Commit 313fb42

Browse files
authored
Support reset_email_by_code template (#1014)
2 parents 3e4f7ce + 0d42545 commit 313fb42

17 files changed

Lines changed: 14783 additions & 17746 deletions

docs/resource-specific-documentation.md

Lines changed: 94 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,6 @@ Contents of `promptName_screenName.json`
116116
}
117117
```
118118

119-
120-
121119
## Databases
122120

123121
When managing database connections, the values of `options.customScripts` point to specific javascript files relative to
@@ -282,3 +280,97 @@ Contents of `password_reset.json`
282280
"name": "password_reset"
283281
}
284282
```
283+
284+
285+
## emailTemplates
286+
287+
When managing email templates, the values of `options.body` and `options.body` point to specific HTML files relative to the path of the output folder. Otherwise, the payload closely matches that of the [Management API](https://auth0.com/docs/api/management/v2#!/Email_Templates/post_email_templates).
288+
289+
**YAML Example**
290+
291+
```
292+
Folder structure when in YAML mode.
293+
294+
./emailTemplates/
295+
./verify_email.html
296+
./welcome_email.html
297+
./password_reset.html
298+
./reset_email.html
299+
./reset_email_by_code.html
300+
./tenant.yaml
301+
```
302+
303+
```yaml
304+
# Contents of ./tenant.yaml
305+
emailTemplates:
306+
- template: "verify_email"
307+
enabled: true
308+
syntax: "liquid"
309+
from: "test@email.com"
310+
subject: "something"
311+
body: "emailTemplates/change_email.html"
312+
313+
- template: "welcome_email"
314+
enabled: true
315+
syntax: "liquid"
316+
from: "test@email.com"
317+
subject: "something"
318+
body: "emailTemplates/change_email.html"
319+
320+
- template: "password_reset"
321+
enabled: true
322+
syntax: "liquid"
323+
from: "test@email.com"
324+
subject: "something"
325+
body: "emailTemplates/change_email.html"
326+
327+
- template: "reset_email_by_code"
328+
enabled: true
329+
syntax: "liquid"
330+
from: "test@email.com"
331+
subject: "something"
332+
body: "emailTemplates/change_email.html"
333+
```
334+
335+
**Directory Example**
336+
337+
```
338+
Folder structure when in directory mode.
339+
./emailTemplates/
340+
./welcome_email.html
341+
./welcome_email.json
342+
./reset_email.html
343+
./reset_email.json
344+
./reset_email_by_code.html
345+
./reset_email_by_code.json
346+
```
347+
348+
Contents of `welcome_email.json`
349+
350+
```json
351+
{
352+
"name": "welcome_email",
353+
"enabled": true,
354+
"html": "./welcome_email.html"
355+
}
356+
```
357+
358+
Contents of `reset_email.json`
359+
360+
```json
361+
{
362+
"name": "reset_email",
363+
"enabled": true,
364+
"html": "./reset_email.html"
365+
}
366+
```
367+
368+
Contents of `reset_email_by_code.json`
369+
370+
```json
371+
{
372+
"name": "reset_email_by_code",
373+
"enabled": true,
374+
"html": "./reset_email_by_code.html"
375+
}
376+
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<html>
2+
<body>
3+
Example Email
4+
</body>
5+
</html>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"template": "reset_email_by_code",
3+
"from": "",
4+
"subject": "",
5+
"resultUrl": "",
6+
"syntax": "liquid",
7+
"body": "./reset_email_by_code.html",
8+
"urlLifetimeInSeconds": 432000,
9+
"enabled": true
10+
}

examples/yaml/tenant.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ emailTemplates:
100100
subject: "something"
101101
body: "emails/change_email.html"
102102

103+
- template: "reset_email_by_code"
104+
enabled: true
105+
syntax: "liquid"
106+
from: "test@email.com"
107+
subject: "something"
108+
body: "emails/change_email.html"
109+
103110

104111
clientGrants:
105112
- client_id: "My M2M"

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"homepage": "https://github.com/auth0/auth0-deploy-cli#readme",
3434
"dependencies": {
3535
"ajv": "^6.12.6",
36-
"auth0": "^4.16.0",
36+
"auth0": "^4.17.0",
3737
"dot-prop": "^5.2.0",
3838
"fs-extra": "^10.1.0",
3939
"global-agent": "^3.0.0",

src/tools/auth0/handlers/connections.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export default class ConnectionsHandler extends DefaultAPIHandler {
148148
include_totals: true,
149149
});
150150

151-
// Filter out database connections
151+
// Filter out database connections as we have separate handler for it
152152
this.existing = connections.filter((c) => c.strategy !== 'auth0');
153153
if (this.existing === null) return [];
154154

src/tools/constants.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const EMAIL_VERIFY = 'verify_email';
1212
const EMAIL_VERIFY_BY_CODE = 'verify_email_by_code';
1313
const EMAIL_RESET = 'reset_email';
1414
const EMAIL_WELCOME = 'welcome_email';
15+
const EMAIL_RESET_BY_CODE = 'reset_email_by_code';
1516
const EMAIL_BLOCKED = 'blocked_account';
1617
const EMAIL_STOLEN_CREDENTIALS = 'stolen_credentials';
1718
const EMAIL_ENROLLMENT = 'enrollment_email';
@@ -51,6 +52,7 @@ const constants = {
5152
'verify_email',
5253
'verify_email_by_code',
5354
'reset_email',
55+
'reset_email_by_code',
5456
'welcome_email',
5557
'blocked_account',
5658
'stolen_credentials',
@@ -73,6 +75,7 @@ const constants = {
7375
EMAIL_VERIFY,
7476
EMAIL_VERIFY_BY_CODE,
7577
EMAIL_RESET,
78+
EMAIL_RESET_BY_CODE,
7679
EMAIL_WELCOME,
7780
EMAIL_BLOCKED,
7881
EMAIL_STOLEN_CREDENTIALS,
@@ -155,6 +158,8 @@ const constants = {
155158
`${EMAIL_VERIFY_BY_CODE}.html`,
156159
`${EMAIL_RESET}.json`,
157160
`${EMAIL_RESET}.html`,
161+
`${EMAIL_RESET_BY_CODE}.json`,
162+
`${EMAIL_RESET_BY_CODE}.html`,
158163
`${EMAIL_WELCOME}.json`,
159164
`${EMAIL_WELCOME}.html`,
160165
`${EMAIL_BLOCKED}.json`,

test/context/yaml/context.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ describe('#YAML context validation', () => {
234234
{ body: './emailTemplates/mfa_oob_code.html', enabled: true, template: 'mfa_oob_code' },
235235
{ body: './emailTemplates/password_reset.html', enabled: true, template: 'password_reset' },
236236
{ body: './emailTemplates/reset_email.html', enabled: true, template: 'reset_email' },
237+
{ body: './emailTemplates/reset_email_by_code.html',enabled: true,template: 'reset_email_by_code' },
237238
{
238239
body: './emailTemplates/stolen_credentials.html',
239240
enabled: true,
@@ -351,6 +352,7 @@ describe('#YAML context validation', () => {
351352
{ body: './emailTemplates/mfa_oob_code.html', enabled: true, template: 'mfa_oob_code' },
352353
{ body: './emailTemplates/password_reset.html', enabled: true, template: 'password_reset' },
353354
{ body: './emailTemplates/reset_email.html', enabled: true, template: 'reset_email' },
355+
{ body: './emailTemplates/reset_email_by_code.html',enabled: true,template: 'reset_email_by_code' },
354356
{
355357
body: './emailTemplates/stolen_credentials.html',
356358
enabled: true,
@@ -469,6 +471,7 @@ describe('#YAML context validation', () => {
469471
{ body: './emailTemplates/mfa_oob_code.html', enabled: true, template: 'mfa_oob_code' },
470472
{ body: './emailTemplates/password_reset.html', enabled: true, template: 'password_reset' },
471473
{ body: './emailTemplates/reset_email.html', enabled: true, template: 'reset_email' },
474+
{ body: './emailTemplates/reset_email_by_code.html',enabled: true,template: 'reset_email_by_code' },
472475
{
473476
body: './emailTemplates/stolen_credentials.html',
474477
enabled: true,

0 commit comments

Comments
 (0)