From 94e9f3bdfc900d098a3355b5300d7b45020e78a7 Mon Sep 17 00:00:00 2001 From: ramya18101 Date: Tue, 7 Jan 2025 08:35:34 +0530 Subject: [PATCH] Support reset_email_by_code email template --- internal/auth/auth.go | 2 +- internal/cli/email_templates.go | 27 +++++++++++++++----------- test/integration/email-test-cases.yaml | 15 ++++++++++++++ 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/internal/auth/auth.go b/internal/auth/auth.go index 0947600e5..81b7f57ac 100644 --- a/internal/auth/auth.go +++ b/internal/auth/auth.go @@ -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", diff --git a/internal/cli/email_templates.go b/internal/cli/email_templates.go index 22988dee0..36b3401c7 100644 --- a/internal/cli/email_templates.go +++ b/internal/cli/email_templates.go @@ -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, @@ -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}, @@ -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: diff --git a/test/integration/email-test-cases.yaml b/test/integration/email-test-cases.yaml index 4ac89be82..9cdf5aaf6 100644 --- a/test/integration/email-test-cases.yaml +++ b/test/integration/email-test-cases.yaml @@ -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 "

Change password (by code)

" --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 ✓ \ No newline at end of file