I generate a custom user token in an ApiController and email it to the user with a callback link using
var token = userManager.GenerateUserToken(user.Id, "ConfirmAction");
var callbackUrl = this.Url.Link("Default", new { controller = "AccountController", action = "ActionXYZ", new { userId = user.Id, token = token} });
When the user click the link I handle it in the MVC Controller with
var validToken = await userManager.VerifyUserTokenAsync(user.Id, "ConfirmAction", token);
if(validToken)
{
// Can token be cancelled to disallow re-use?
}
Is there a way to prevent the token being used more than once without saving the token in the database? Eg some kind of earlier expiry for a specific token?