Set reset-password token into useraccounts-bootstrap

Hello,

I am implementing the reset-password using react and useraccounts-bootstrap packages, however i got this error when i click the reset password button in the ui:

Uncaught errorClass {message: "Match error: Expected string, got null", path: "", sanitizedError: errorClass, errorType: "Match.Error", stack: "Error↵    at exports.check (http://localhost:3000/…=f33d3dfed63a491d24e3aa07ad66c24b5fe8c761:863:24)"}

I changed the url with this:

Accounts.urls.resetPassword = (token) => {
  return Meteor.absoluteUrl(`accounts/reset-password/${token}`);
};

I have configured the FlowRouter with these two routes:

// Render the form to request the email
FlowRouter.route('/accounts/password-recovery', {
  name: 'accounts.password-recovery',
  action(params) {
    mount(SignupPage, {
      content: 'passwordRecovery',
    });
  },
});
// Render the form to set the new password, accessed from the link sent by email
FlowRouter.route('/accounts/reset-password/:token', {
  name: 'accounts.reset-password',
  action(params) {
    mount(SignupPage, {
      content: 'resetPassword',
    });
  },
});

And “passwordRecovery” and “resetPassword” are resolved in the SignupPage using two components that lock up the at form using these:

<LoginContainer atFormState="forgotPwd" />

and

<LoginContainer atFormState="resetPwd" />

So, I think that the error could be happening because I am not passing the token into the reset form. is that correct? In that case, how do I pass the token into the at-form?.. I do not want to implement my own reset form…

I fixed it using this:

AccountsTemplates.paramToken = token;

So, the code is as follow:

FlowRouter.route('/accounts/reset-password/:token', {
  name: 'accounts.reset-password',
  action(params) {
    AccountsTemplates.paramToken = params.token;
    mount(SignupPage, {
      content: 'resetPassword',
    });
  },
});

I deleted the route “/accounts/password-recovery” because now I use the the included in useraccounts package, blocking the at-form with “resetPwd”.

With this reset password works, but it does not redirect once the password is changed. So I added these lines to the hook “onSubmitHook” of the useraccounts package:

if (state === 'resetPwd') {
  FlowRouter.go('/dashboard');
}

Hope this help someone else.

I’ve encountered the same (or a very similar) problem:

errorClass {message: "Match error: Expected string, got undefined", path: "", sanitizedError: errorClass, errorType: "Match.Error", stack: "Error: Match error: Expected string, got undefined…=a1ff2d6d5ecd59ee11e2ba260b8650a9d1140f59:863:24)"}

I’m not using any custom routes in FlowRouter, instead having this in my main template:

{{#unless currentUser }}
    {{> atForm }}
{{/unless}}

Here’s my (probably incorrect) setup for the accounts package:


AccountsTemplates.configure({
    showForgotPasswordLink: true,
    enablePasswordChange: true,
    sendVerificationEmail: true,
    enforceEmailVerification: false,
    confirmPassword: true,
    showResendVerificationEmailLink: true,
    continuousValidation: true,

    // Privacy Policy and Terms of Use
    privacyUrl: 'privacy',
    //termsUrl: 'terms-of-use',

    // Display the form properly
    defaultLayoutType: 'blaze',
    defaultLayout: 'MainLayout',
    defaultLayoutRegions: { },
    defaultContentRegion: 'content'
});

AccountsTemplates.configureRoute('resetPwd');

Do you have any suggestions, or may I see your configuration, please? it may be helpful in working out how to fix this.

It could be because you are not setting the validation token, you have to use:

AccountsTemplates.paramToken = token;

before loading the template. In my case i did it in the router file (i use FlowRouter):

FlowRouter.route('/accounts/reset-password/:token', {
  name: 'accounts.reset-password',
  action(params) {
    AccountsTemplates.paramToken = params.token;
    mount(SignupPage, {
      content: 'resetPassword',
    });
  },
});

My configuration file is same than yours except for the attribute enforceEmailVerification that you have set to false, i set it to true.

Thanks for replying.
I’d already tried what you’re suggesting there, though using the route /reset-password/:token, but with no luck.
I’m not entirely sure what is happening, but upon going to the reset URL sent by the application it redirects to /accounts. Does the route for AccountsTemplates.configureRoute('resetPwd'); need to be specified somewhere?

I also use FlowRouter, BTW.

Looks like the redirection problem has been solved - it was some code of mine in client/main.js (written as an attempt to fix an annoying problem when using the app on iOS) interfering with things.