aspnet / Identity

[Archived] ASP.NET Core Identity is the membership system for building ASP.NET Core web applications, including membership, login, and user data. Project moved to https://github.com/aspnet/AspNetCore
Apache License 2.0
1.96k stars 869 forks source link

AS.NET Core 2.1 - Password forgot: Invalid Token #1955

Closed sintetico82 closed 5 years ago

sintetico82 commented 5 years ago

Hello, I have the invalid code on the forgot password procedure. In the razor pages scaffolding template i have:

the ForgotPassword razor page

                // For more information on how to enable account confirmation and password reset please 
                // visit https://go.microsoft.com/fwlink/?LinkID=532713
                var code = await _userManager.GeneratePasswordResetTokenAsync(user);
                var callbackUrl = Url.Page(
                    "/Account/ResetPassword",
                    pageHandler: null,
                    values: new { code },
                    protocol: Request.Scheme);
                await _emailSender.SendEmailAsync(
                    Input.Email,
                    "Reset Password",
                    $"PEr eseguire il reset della password <a href='{ HtmlEncoder.Default.Encode(callbackUrl)}'>seguire questo link</a>.");

                return RedirectToPage("./ForgotPasswordConfirmation");

It encode the token but when the token arrive on the ResetPassword razor page it dosent decode as well:

 public IActionResult OnGet(string code = null)
        {
            if (code == null)
            {
                return BadRequest("A code must be supplied for password reset.");
            }
            else
            {
                Input = new InputModel
                {
                    Code = code
                };
                return Page();
            }
        }

So they are different.