Skip to content

Commit

Permalink
Support reset_email_by_code email template
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya18101 committed Jan 7, 2025
1 parent da13038 commit 94e9f3b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 12 deletions.
2 changes: 1 addition & 1 deletion internal/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ var RequiredScopes = []string{
"create:rules", "delete:rules", "read:rules", "update:rules",
"create:users", "delete:users", "read:users", "update:users",
"read:branding", "update:branding",
"read:email_templates", "update:email_templates",
"create:email_templates", "read:email_templates", "update:email_templates",
"read:email_provider",
"read:flows", "read:forms", "read:flows_vault_connections",
"read:connections", "update:connections",
Expand Down
27 changes: 16 additions & 11 deletions internal/cli/email_templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,26 @@ import (
)

const (
emailTemplateVerifyLink = "verify-link"
emailTemplateVerifyCode = "verify-code"
emailTemplateChangePassword = "change-password"
emailTemplateWelcome = "welcome"
emailTemplateBlockedAccount = "blocked-account"
emailTemplatePasswordBreach = "password-breach"
emailTemplateMFAEnrollment = "mfa-enrollment"
emailTemplateMFACode = "mfa-code"
emailTemplateUserInvitation = "user-invitation"
emailTemplateVerifyLink = "verify-link"
emailTemplateVerifyCode = "verify-code"
emailTemplateChangePassword = "change-password"
emailTemplateChangePasswordCode = "change-password-code"
emailTemplateWelcome = "welcome"
emailTemplateBlockedAccount = "blocked-account"
emailTemplatePasswordBreach = "password-breach"
emailTemplateMFAEnrollment = "mfa-enrollment"
emailTemplateMFACode = "mfa-code"
emailTemplateUserInvitation = "user-invitation"
)

var (
emailTemplateTemplate = Argument{
Name: "Template",
Help: fmt.Sprintf("Template name. Can be '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' or '%s'",
Help: fmt.Sprintf("Template name. Can be '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' or '%s'",
emailTemplateVerifyLink,
emailTemplateVerifyCode,
emailTemplateChangePassword,
emailTemplateChangePasswordCode,
emailTemplateWelcome,
emailTemplateBlockedAccount,
emailTemplatePasswordBreach,
Expand Down Expand Up @@ -89,7 +91,8 @@ var (
emailTemplateOptions = pickerOptions{
{"Verification Email (using Link)", emailTemplateVerifyLink},
{"Verification Email (using Code)", emailTemplateVerifyCode},
{"Change Password", emailTemplateChangePassword},
{"Change Password (using Link)", emailTemplateChangePassword},
{"Change Password (using Code)", emailTemplateChangePasswordCode},
{"Welcome Email", emailTemplateWelcome},
{"Blocked Account Email", emailTemplateBlockedAccount},
{"Password Breach Alert", emailTemplatePasswordBreach},
Expand Down Expand Up @@ -304,6 +307,8 @@ func apiEmailTemplateFor(v string) string {
return "verify_email_by_code"
case emailTemplateChangePassword:
return "reset_email"
case emailTemplateChangePasswordCode:
return "reset_email_by_code"
case emailTemplateWelcome:
return "welcome_email"
case emailTemplateBlockedAccount:
Expand Down
15 changes: 15 additions & 0 deletions test/integration/email-test-cases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,18 @@ tests:
syntax: "liquid"
urlLifetimeInSeconds: "6100"
enabled: "true"
021 - it successfully updates change-password-code email template:
command: auth0 email templates update change-password-code --enabled --body "<h1>Change password (by code)</h1>" --from "change-password-by-code@travel0.com" --lifetime 6100 --subject "Change password by code" --url "travel0.com" --force
exit-code: 0

022 - it successfully shows change-password-code email template:
command: auth0 email templates show change-password-code
exit-code: 0
stdout:
contains:
- TEMPLATE reset_email_by_code
- FROM change-password-by-code@travel0.com
- SUBJECT Change password (by code)
- RESULT URL travel0.com
- RESULT URL LIFETIME 6100
- ENABLED ✓

0 comments on commit 94e9f3b

Please sign in to comment.