knirirr
knirirr

Reputation: 2807

Meteor application reset password

I'm using meteor-accounts and accounts-password in an application and would like users to be able to reset their passwords. At present there's no need for any customisation of any of the forms and so I've used a common layout with {{> atForm }} and a configuration file of /lib/config.js containing the following:

AccountsTemplates.configure({
    showForgotPasswordLink: true,
    enablePasswordChange: true,
    sendVerificationEmail: true,
    enforceEmailVerification: true,
    confirmPassword: true,
    showResendVerificationEmailLink: true,
    continuousValidation: true,
    privacyUrl: 'privacy',
 });

Clicking on a 'reset password' link produces URLs like the following:

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

However, these are completely useless in that they redirect to the root URL for the application whilst apparently changing the password; users therefore can't log in after clicking on one of these links. A user account looks like this after clicking one:

{ "_id" : "LcQSCiG7ib5F49tPN", "createdAt" : ISODate("2017-03-04T21:33:57.050Z"), "services" : { "password" : { "bcrypt" : "<redacted>", "reset" : { "token" : "l4HdPzoKkeIUdUeUC5x9NmUiQMnRsY1MRLvYk6Wvqw1", "email" : "<redacted>", "when" : ISODate("2017-03-04T21:51:32.171Z"), "reason" : "reset" } }, "email" : { "verificationTokens" : [ { "token" : "K88HXjzI2UO8vARZv6l6Qf0mUJ1hstInnrJK-8hayzk", "address" : "<redacted>", "when" : ISODate("2017-03-04T21:33:57.072Z") }, { "token" : "NMGLelAWKcCFglRj7aQvZoP85N-_YdWJZ2FcPWu5U8D", "address" : "<redacted>", "when" : ISODate("2017-03-04T21:52:55.930Z") } ] }, "resume" : { "loginTokens" : [ ] } }, "emails" : [ { "address" : "<redacted>", "verified" : false } ] }

Everything else works (e.g. signing up with confirmation emails). I'm using Blaze templates and Flow Router including useraccounts:flow-routing.

I seem to be missing something here and would appreciate it if someone would be able to point me in the correct direction to get this working.

Upvotes: 0

Views: 622

Answers (1)

jordanwillis
jordanwillis

Reputation: 10705

Based on your explanation, I think you are missing some keys things to get this working.

First, remember that useraccounts:flow-routing does not provide routes out of the box.

There are no routes provided by default, but you can easily configure routes for sign in, sign up, forgot password, reset password, change password, enroll account using AccountsTemplates.configureRoute

Given that info, you need to at least configure the default route for reset password.

The simplest way is to make the call passing in only a route code (available route codes are: signIn, signUp, changePwd, forgotPwd, resetPwd, enrollAccount).

Here is an example.

AccountsTemplates.configureRoute('resetPwd');

The default will route the user to the fullPageAtForm so they can re-enter a new password.

Take a look at the useraccounts:flow-routing readme for more details.

Upvotes: 1

Related Questions