Skip to content

Commit

Permalink
Support reset_email_by_code template (#1014)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya18101 authored Jan 29, 2025
2 parents 3e4f7ce + 0d42545 commit 313fb42
Show file tree
Hide file tree
Showing 17 changed files with 14,783 additions and 17,746 deletions.
96 changes: 94 additions & 2 deletions docs/resource-specific-documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ Contents of `promptName_screenName.json`
}
```



## Databases

When managing database connections, the values of `options.customScripts` point to specific javascript files relative to
Expand Down Expand Up @@ -282,3 +280,97 @@ Contents of `password_reset.json`
"name": "password_reset"
}
```


## emailTemplates

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).

**YAML Example**

```
Folder structure when in YAML mode.
./emailTemplates/
./verify_email.html
./welcome_email.html
./password_reset.html
./reset_email.html
./reset_email_by_code.html
./tenant.yaml
```

```yaml
# Contents of ./tenant.yaml
emailTemplates:
- template: "verify_email"
enabled: true
syntax: "liquid"
from: "[email protected]"
subject: "something"
body: "emailTemplates/change_email.html"

- template: "welcome_email"
enabled: true
syntax: "liquid"
from: "[email protected]"
subject: "something"
body: "emailTemplates/change_email.html"

- template: "password_reset"
enabled: true
syntax: "liquid"
from: "[email protected]"
subject: "something"
body: "emailTemplates/change_email.html"

- template: "reset_email_by_code"
enabled: true
syntax: "liquid"
from: "[email protected]"
subject: "something"
body: "emailTemplates/change_email.html"
```
**Directory Example**
```
Folder structure when in directory mode.
./emailTemplates/
./welcome_email.html
./welcome_email.json
./reset_email.html
./reset_email.json
./reset_email_by_code.html
./reset_email_by_code.json
```

Contents of `welcome_email.json`

```json
{
"name": "welcome_email",
"enabled": true,
"html": "./welcome_email.html"
}
```

Contents of `reset_email.json`

```json
{
"name": "reset_email",
"enabled": true,
"html": "./reset_email.html"
}
```

Contents of `reset_email_by_code.json`

```json
{
"name": "reset_email_by_code",
"enabled": true,
"html": "./reset_email_by_code.html"
}
```
5 changes: 5 additions & 0 deletions examples/directory/emails/reset_email_by_code.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html>
<body>
Example Email
</body>
</html>
10 changes: 10 additions & 0 deletions examples/directory/emails/reset_email_by_code.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"template": "reset_email_by_code",
"from": "",
"subject": "",
"resultUrl": "",
"syntax": "liquid",
"body": "./reset_email_by_code.html",
"urlLifetimeInSeconds": 432000,
"enabled": true
}
7 changes: 7 additions & 0 deletions examples/yaml/tenant.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ emailTemplates:
subject: "something"
body: "emails/change_email.html"

- template: "reset_email_by_code"
enabled: true
syntax: "liquid"
from: "[email protected]"
subject: "something"
body: "emails/change_email.html"


clientGrants:
- client_id: "My M2M"
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"homepage": "https://github.com/auth0/auth0-deploy-cli#readme",
"dependencies": {
"ajv": "^6.12.6",
"auth0": "^4.16.0",
"auth0": "^4.17.0",
"dot-prop": "^5.2.0",
"fs-extra": "^10.1.0",
"global-agent": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/tools/auth0/handlers/connections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export default class ConnectionsHandler extends DefaultAPIHandler {
include_totals: true,
});

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

Expand Down
5 changes: 5 additions & 0 deletions src/tools/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const EMAIL_VERIFY = 'verify_email';
const EMAIL_VERIFY_BY_CODE = 'verify_email_by_code';
const EMAIL_RESET = 'reset_email';
const EMAIL_WELCOME = 'welcome_email';
const EMAIL_RESET_BY_CODE = 'reset_email_by_code';
const EMAIL_BLOCKED = 'blocked_account';
const EMAIL_STOLEN_CREDENTIALS = 'stolen_credentials';
const EMAIL_ENROLLMENT = 'enrollment_email';
Expand Down Expand Up @@ -51,6 +52,7 @@ const constants = {
'verify_email',
'verify_email_by_code',
'reset_email',
'reset_email_by_code',
'welcome_email',
'blocked_account',
'stolen_credentials',
Expand All @@ -73,6 +75,7 @@ const constants = {
EMAIL_VERIFY,
EMAIL_VERIFY_BY_CODE,
EMAIL_RESET,
EMAIL_RESET_BY_CODE,
EMAIL_WELCOME,
EMAIL_BLOCKED,
EMAIL_STOLEN_CREDENTIALS,
Expand Down Expand Up @@ -155,6 +158,8 @@ const constants = {
`${EMAIL_VERIFY_BY_CODE}.html`,
`${EMAIL_RESET}.json`,
`${EMAIL_RESET}.html`,
`${EMAIL_RESET_BY_CODE}.json`,
`${EMAIL_RESET_BY_CODE}.html`,
`${EMAIL_WELCOME}.json`,
`${EMAIL_WELCOME}.html`,
`${EMAIL_BLOCKED}.json`,
Expand Down
3 changes: 3 additions & 0 deletions test/context/yaml/context.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ describe('#YAML context validation', () => {
{ body: './emailTemplates/mfa_oob_code.html', enabled: true, template: 'mfa_oob_code' },
{ body: './emailTemplates/password_reset.html', enabled: true, template: 'password_reset' },
{ body: './emailTemplates/reset_email.html', enabled: true, template: 'reset_email' },
{ body: './emailTemplates/reset_email_by_code.html',enabled: true,template: 'reset_email_by_code' },
{
body: './emailTemplates/stolen_credentials.html',
enabled: true,
Expand Down Expand Up @@ -351,6 +352,7 @@ describe('#YAML context validation', () => {
{ body: './emailTemplates/mfa_oob_code.html', enabled: true, template: 'mfa_oob_code' },
{ body: './emailTemplates/password_reset.html', enabled: true, template: 'password_reset' },
{ body: './emailTemplates/reset_email.html', enabled: true, template: 'reset_email' },
{ body: './emailTemplates/reset_email_by_code.html',enabled: true,template: 'reset_email_by_code' },
{
body: './emailTemplates/stolen_credentials.html',
enabled: true,
Expand Down Expand Up @@ -469,6 +471,7 @@ describe('#YAML context validation', () => {
{ body: './emailTemplates/mfa_oob_code.html', enabled: true, template: 'mfa_oob_code' },
{ body: './emailTemplates/password_reset.html', enabled: true, template: 'password_reset' },
{ body: './emailTemplates/reset_email.html', enabled: true, template: 'reset_email' },
{ body: './emailTemplates/reset_email_by_code.html',enabled: true,template: 'reset_email_by_code' },
{
body: './emailTemplates/stolen_credentials.html',
enabled: true,
Expand Down
Loading

0 comments on commit 313fb42

Please sign in to comment.