Reset Password custom template

Hi All:

In my Meteor-Angular app, I’m trying to customize the email that is sent with a sendPasswordReset request.
I’ve created a emails.ts file on the server side with the following:

import { Accounts } from 'meteor/accounts-base';

Accounts.emailTemplates.siteName = "Site Test";
Accounts.emailTemplates.from = "test.ca";

Accounts.emailTemplates.resetPassword = {
    subject() {
        return "[test] Reset Password Request";
    },
    text( user, url ) {
        let emailAddress = user.emails[0].address,
        urlWithOutHash = url.replace( '#/', '' ),
        emailBody = `We received an account recovery request on test.ca for {{emailAddress}}.\n\n
        If you initiated this request, click this link to reset your password.\n
        {{urlWithOutHash}}\n\n
        If you did not initiate this account recovery request, just ignore this email. We'll keep your account safe.`
        return emailBody;
    }
};

However, every time I submit a recover password request I received the canned response:

Hello, 

To reset your password, simply click the link below. 

http://localhost:3000/#/reset-password/TUHClXy9QSKs4udIFTHL1wTw9JKo72kC29hUvx893d3 

Thanks.

Any suggestions would be appreciated.

Thanks!

It looks like you want to change the URL that gets generated, this is what I use:
(there is a URL generator you might not know about)

Accounts.urls.resetPassword = function(token) {
  return Meteor.absoluteUrl('reset/' + token);
}

I just realised that your template isn’t being used at all!
The comment above still stands.
Where are you running that server code?
Are you sure you are including that file in the startup sequence of the server block???
Put a couple console.log() statements in to see if the meteor server console spits it back…

1 Like

You’re awesome!

Thanks for the quick response.
Changing the URL was exactly what I was going for and I didn’t include the code in the startup.
Your suggestions worked.

Thanks again!

No problem!
I do the same thing every now and then, just forget the file isn’t actually being run anywhere yet!