AspNetIdentity icon indicating copy to clipboard operation
AspNetIdentity copied to clipboard

Checking to see if email confirmation token has expired

Open egmfrs opened this issue 7 years ago • 3 comments
trafficstars

Is there a way to do this? Like an error code that will return when the email confirmation token has expired? For example if the error code was "TokenExpired" I could use the following to return the user to a specific view which gives them advice on a process to follow if their token has expired:

        var result = await _userManager.ConfirmEmailAsync(user, code);
        if (result.Succeeded) return View("ConfirmEmail");

        return View(result.Errors.Any(c => c.Code == "TokenExpired") ? "TokenExpired" : "Error");

egmfrs avatar Jun 21 '18 14:06 egmfrs

@egmfrs take a look at this https://github.com/aspnet/Identity/issues/307#issuecomment-407731661 I had same problem.

Misiu avatar Jul 25 '18 13:07 Misiu

Thanks for sharing @Misiu

egmfrs avatar Jul 25 '18 13:07 egmfrs

@egmfrs please let me know if this will work for You. I've created that code a couple of hours ago and it still needs tests, so any comments are more than welcome.

Misiu avatar Jul 25 '18 13:07 Misiu