Asp.Net Core Identity
I have a question regarding VerifyUserTokenAsync
If the user forgets the password, I'll provide a page to indicate the email and send a url that has the UserId and Token (by default):
private async Task EsqueciMinhaSenhaAsync(EsqueciMinhaSenhaViewModel model)
{
var user = await _userManager.FindByEmailAsync(model.Email);
if (user != null)
{
var token = await _userManager.GeneratePasswordResetTokenAsync(user);
var callbackUrl = Url.Action("ResetarSenha", "Auth", new { userId = user.Id, token = token}, protocol: HttpContext.Request.Scheme);
//TODO: enviar e-mail
}
}
When the user accesses the generated url, I will call the following code snippet (which verifies that the token ) is valid, otherwise I will redirect through the controller warning that the request has expired, for example):
public async Task<bool> VerificarTokenValidoAsync(ApplicationUser user, string token)
{
return await _userManager.VerifyUserTokenAsync(user, string.Empty, "ResetPassword", token))
}
My question is in the VerifyTokenValidoAsync method, I use it to verify that the token is valid before giving the access of the page where the user will provide a new password, however, it gets in the second parameter (where I left string.Empty ), one of > tokenProvider , I would like to know what this parameter is about and how I can generate it.
Update 01/03/2018
I have been able to use the method, there is a TokenOptions class where it provides the default providerToken :
_userManager.VerifyUserTokenAsync(user, TokenOptions.DefaultProvider, proposito, token)
In this way, it worked correctly, however, the only problem now is that the result always returns false .