Reputation: 99
I am trying to confirm the email, but the moment I try to confirm it, it indicates that the token is invalid, validate the token with a stop point and it is correct, I do not know what could be happening,
This is my method that sends me the email with the user and the token,
This is the method when I am trying to confirm the email and it is the one that tells me that the invalid token,
Try encoding the token with url encode and it didn't work for me, I would appreciate the help
Upvotes: 0
Views: 100
Reputation: 27588
That is because you are creating new users right before your generate the token, its relying on the security stamp which is expected to be stable . So instead of create a new User
entity , directly get user from database :
var myUser = await _userManager.FindByIdAsync(userId);
string mytoken= await _userManager.GenerateEmailConfirmationTokenAsync(myUser);
Upvotes: 1