Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support reset_email_by_code template #1014

Merged
merged 7 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading