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

auth0.EmailTemplate does not work for the change_password template type #311

Closed
1tmb opened this issue Oct 3, 2023 · 1 comment
Closed
Labels
kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team

Comments

@1tmb
Copy link

1tmb commented Oct 3, 2023

What happened?

  1. Followed https://www.pulumi.com/registry/packages/auth0/api-docs/emailtemplate/#auth0-emailtemplate
  2. Pulumi plan suggests a chance which looks correct
  3. Pulumi update uploads resource and says that the upload has been successful

Expected: template updated in Auth0
Actual: template unchanged in Auth0

Example

import { Input, Resource } from "@pulumi/pulumi";
import * as fs from "fs";
import path = require("path");

function getHtmlTemplateAsString(path: string): string {
  try {
    const html = fs.readFileSync(path, "utf8");
    return html;
  } catch (err) {
    console.error("Error reading file:", err);
    return "";
  }
}

export function getChangePasswordEmailTemplate(
  supportEmailAddress: string,
  emailProvider: Input<Resource>
) {
  const templateLocation = path.resolve(
    __dirname,
    "./templates/change-password.html"
  );
  const html = getHtmlTemplateAsString(templateLocation);
  return new auth0.EmailTemplate(
    "changePasswordEmailTemplate",
    {
      body: html,
      from: supportEmailAddress,
      enabled: true,
      subject: "Reset your password",
      syntax: "liquid",
      template: "change_password",
      urlLifetimeInSeconds: 3600,
    },
    {
      dependsOn: [emailProvider],
    }
  );
}

const apiKey = "myApiKey"
const supportEmailAddress = "[email protected]"
export const emailProvider = configureEmailProvider(apiKey, supportEmailAddress);
export const passwordResetEmailTemplate = getChangePasswordEmailTemplate(supportEmailAddress, emailProvider);

Output of pulumi about

CLI
Version 3.86.0
Go Version go1.21.1
Go Compiler gc

Plugins
NAME VERSION
auth0 2.24.3
nodejs unknown

Host
OS fedora
Version 38
Arch x86_64

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

@1tmb 1tmb added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Oct 3, 2023
@1tmb 1tmb changed the title auth0.EmailTemplate doesn't work auth0.EmailTemplate does not work Oct 3, 2023
@1tmb 1tmb changed the title auth0.EmailTemplate does not work auth0.EmailTemplate does not work for the change_password template type Oct 3, 2023
@1tmb
Copy link
Author

1tmb commented Oct 3, 2023

Closing as not an issue. After digging into the issue in lieu of documentation (sigh), I have learned that this is caused by configuration. This is solved as follows:

 return new auth0.EmailTemplate(
    "reset_email",
    {
      body: html,
      from: supportEmailAddress,
      enabled: true,
      subject: "Reset your password",
      syntax: "liquid",
      template: "reset_email",
      urlLifetimeInSeconds: 3600,
    },
    {
      dependsOn: [emailProvider],
    }
  );

The changes are as follows:

  1. change_password is apparently deprecated in favour of reset_email
  2. To resolve the less than helpful error message "the template property provided in payload must match the template in the URL" you need to ensure that the name argument is the same string value as the template argument.

@1tmb 1tmb closed this as completed Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team
Projects
None yet
Development

No branches or pull requests

1 participant