Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meteor reset password - clicking on e-mail link doesn't work

Trying to implement password recovery in my meteor app.

I can generate an recovery email which points to my app :

onemore.meteor.com/#/reset-Password/[token]

When I click on this link, it goes to the URL, but then the URL immediately rewrites to onemore.meteor.com/#

When I type Session.get("resetPassword"), it returns undefined

I know the token is valid. If I copy the latter part of the link in the e-mail "[token]" and paste it into console, as Session.set("resetPassword",[token]), the password recovery form acts as expected.

Why does my URL rewrite onload? Should this happen? Is there js that I need to interpret this before the rewrite?

Thanks

like image 926
user3744242 Avatar asked Jun 18 '14 21:06

user3744242


3 Answers

You might try removing the # from reset URL with something like this:

Meteor.startup(function () {       

  Accounts.emailTemplates.resetPassword.text = function (user, url) {
     url = url.replace('#/', '')
     return " To reset your password, simply click the link below:\n\n"
       + url;
  };
});

See also How do you change the reset password URL in meteor?

like image 54
Alex Webster Avatar answered Sep 24 '22 02:09

Alex Webster


I think you need to add the route by yourself.

For iron router with coffeescript it may like

Router.route '#/reset_password/:token',
  name: 'reset_password'
  onBeforeAction: ()->
    if Meteor.userId() then this.redirect('/') else this.next()
    Accounts._resetPasswordToken = this.params.token

And you should also add the reset_password template.

like image 38
Xiangshen.Meng Avatar answered Sep 23 '22 02:09

Xiangshen.Meng


You can set the URL as follows:

Meteor.startup(() => {
    Accounts.urls.resetPassword= (token)  => {
        return Meteor.absoluteUrl('reset-password/' + token);
    };
});

Thats better than replacing the whole email text.

like image 1
basti500 Avatar answered Sep 22 '22 02:09

basti500