Invalid token in ASP.NET CORE 2.1?

asp.net-core entity-framework-core

Question

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,

enter image description here

This is the method when I am trying to confirm the email and it is the one that tells me that the invalid token,

enter image description here

Try encoding the token with url encode and it didn't work for me, I would appreciate the help

1
0
4/9/2020 12:02:23 AM

Accepted Answer

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);
1
4/9/2020 2:52:27 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow