Search code examples
meteormeteor-accountsflow-router

Meteor FlowRouter getParam error


I have a route to reset password that setup like this:

FlowRouter.route('/reset-password/:token',{
    name:'reset-password',
    action(){
        BlazeLayout.render('MainFullLayout',{main:'ResetPassword'});
    }
});

So that when I want to access it i can just:

var tokenVar = FlowRouter.getParam("token");

But when I use it in Accounts.resetPassword() :

Template.ResetPassword.events({
    'submit #resetpassword-form': function(event){
        event.preventDefault();
        var newPasswordVar = event.target.resetNewPassword.value;
        var tokenVar = FlowRouter.getParam("token");
        Accounts.resetPassword({
            token: tokenVar,
            password: newPasswordVar
        });
    }
  });

I got an error:

Uncaught Error: Match error: Expected string, got object

How can I resolve this?


Solution

  • The call to resetPassword should look like this:

    Accounts.resetPassword(tokenVar, newPasswordVar);