Oh my, you do not know how long I've been struggling with this aswell a few weeks ago, haha, token was always invalid for some reason.
In the end I chose a different route.
I generated my own guid (key) and stored it with the member properties, and send it with the email.
When the user clicks the link in the email, the guid is attached to the URL, so you can verify it on the backend.
Then instead of using the ChangePasswordWithResetAsync method, I did something like this:
//Injected
private readonly IPasswordChanger<MemberIdentityUser> _passwordChanger;
//Code
//Check if supplied Guid matches the member being reset
//If so, reset password:
var changePasswordModel = new ChangingPasswordModel()
{
Id = Convert.ToInt32(member.Id),
NewPassword = model.ConfirmPassword,
OldPassword = null
};
await _passwordChanger.ChangePasswordWithIdentityAsync(changePasswordModel , _memberManager);
Ha, glad to hear it's not just me! I used your method on older versions of Umbraco but saw the new API and assumed _memberManager.GeneratePasswordResetTokenAsync is the correct way to go now.
Maybe someone wiser than me can shed some light, but in the mean time I've just used your method.
Hello,
I had the same issue while I was doing a forgot password feature.
Turns out that the problem was the translated token on the email so I encoded the token before send the email:
HttpUtility.UrlEncode(token)
This way you won't have issues with unwanted characters or blanks spaces on the generated token
Member Forgot Password Feature
Hi guys,
I'm having trouble implementing a password reset feature for members who have forgotton their password.
The flow is fairly standard:
IMemberManager
GeneratePasswordResetTokenAsync(member)
IMemberManager
ResetPasswordAsync
ORChangePasswordWithResetAsync
Neither of these methods works though, I keep getting TokenInvalid error, no matter what I try.
Am I missing something? Or am I barking up the wrong tree?
Any help is greatly appreciated!
Oh my, you do not know how long I've been struggling with this aswell a few weeks ago, haha, token was always invalid for some reason.
In the end I chose a different route.
I generated my own guid (key) and stored it with the member properties, and send it with the email.
When the user clicks the link in the email, the guid is attached to the URL, so you can verify it on the backend.
Then instead of using the ChangePasswordWithResetAsync method, I did something like this:
And it works!
Ha, glad to hear it's not just me! I used your method on older versions of Umbraco but saw the new API and assumed
_memberManager.GeneratePasswordResetTokenAsync
is the correct way to go now.Maybe someone wiser than me can shed some light, but in the mean time I've just used your method.
Gracias amigo
That was exactly my initial plan..haha!
You're welcome!
Hello,
I did a RequstChange, where i crate a token:
This token is sent with the email, and on the reset password page I stored the token in a hidden field so in the API look like this.
Hello, I had the same issue while I was doing a forgot password feature. Turns out that the problem was the translated token on the email so I encoded the token before send the email:
HttpUtility.UrlEncode(token)
This way you won't have issues with unwanted characters or blanks spaces on the generated token
Ran into the whole invalid token thing as well, Rafael, you champ, worked a treat.
is working on a reply...