Reset password form - Token is always expired (SOLVED)

I am trying to create a reset password form and use the Accounts.resetPassword method on the client to do it. Every time i try to change the password, it says that the token has expired, no matter how much time has passed.

this.token contains the token
this.password contains the new password

          Accounts.resetPassword(this.token, this.password, error => {
            if (error) {
              console.log(error);
              this.error = error.reason;
              this.hasError = true;
            } else {
              this.passwordReset = true;
            }
          })

Since you use fat arrow function. I’m guessing you should not use the this element but rather use an object. Reading the doc shows that you are doing it right so the issue must reside in the details…

1 Like

Tried also with normal function and still having the same issue.

did you try without the object this. ? sometimes it is misleading…

You mean removing them from the callback? Yes i tried and nothing changed.

No I mean using single variables like token and password and just logging inside your callback first

Yes I tried it and no changes. I also tried to use token and password strings directly on the resetPassword method and still getting the token expired error.

Are you sure you are copy/pasting the token right ?
I had issue with not copying completely from server console (multi lines) or leaving the = from end of string in the html mail.

1 Like

Yes an example is here

I remove the blue characters and i have the full url to use combining the two lines

2 Likes

And you forgot to remove the = added at mail end of line :stuck_out_tongue: (I did the same not so long ago)

7 Likes

Had to remove the = ??? Had no idea man! Thank you so much, I ve been trying to solve this for a long time :sweat_smile:

1 Like

Hi, just to say thank, I just spent an hour trying to fix this! I was suspecting this “=” but couldn’t figure out the correct token.

1 Like

thanks for sharing this issue, the solution helped me even now a year later.

2 Likes

thanks for the solution. Even I was stuck on this, trying to figure out what’s wrong. Appreciate your help.

2 Likes