Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with change email confirmation after scaffolding #32

Open
DotNetDublin opened this issue Aug 10, 2020 · 1 comment
Open

Problem with change email confirmation after scaffolding #32

DotNetDublin opened this issue Aug 10, 2020 · 1 comment

Comments

@DotNetDublin
Copy link

Hi,

After I scaffolded ASP.NET Core Identity into my Blazor (Server) project I noticed that I was unable to change email address using the function presented on Account\Manage\Email.cshtml

The email confirmation would send as expected however when I clicked on the link the value of result.Succeeded on line 42 of Account\ConfirmEmailChange.cshtml.cs was always false.

code = Encoding.UTF8.GetString(WebEncoders.Base64UrlDecode(code));
var result = await _userManager.ChangeEmailAsync(user, email, code);
if (!result.Succeeded)
{
	StatusMessage = "Error changing email.";
	return Page();
}

In noticed on Account\Manage\Email.cshtml.cs that within OnPostSendVerificationEmailAsync() after the token code was generated on line 129 using await _userManager.GenerateEmailConfirmationTokenAsync(user) that it was then encoded using code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code));

This encoding is missing within OnPostChangeEmailAsync() after var code = await _userManager.GenerateChangeEmailTokenAsync(user, Input.NewEmail); on line 93.

When I add code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code)); to line 94 the issue is resolved and result.Succeeded returns true.

Thanks

@tymur999
Copy link

tymur999 commented Oct 8, 2020

Yes. This is the same solution as what I did

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants