-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
EmailConfirmed set to false when updating name #7430
Comments
Unable reproduce. |
@maliming try this code and see if you get the same result. Steps to reproduce
CodeConfirmEmail.cs @page
@model Test.Abp412Clean.Web.Pages.ConfirmEmailModel
@{
}
ConfirmEmail.cshtml.cs using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http.Extensions;
using Microsoft.AspNetCore.Identity;
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages;
using Volo.Abp.Identity;
using IdentityUser = Volo.Abp.Identity.IdentityUser;
namespace Test.Abp412Clean.Web.Pages
{
public class ConfirmEmailModel : AbpPageModel
{
private readonly IdentityUserManager _identityUserManager;
public ConfirmEmailModel(IdentityUserManager identityUserManager)
{
_identityUserManager = identityUserManager;
}
public async Task OnGet(string token)
{
try
{
if (!CurrentUser.IsAuthenticated)
{
Alerts.Danger("Log in first");
return;
}
var user = await _identityUserManager.GetByIdAsync((Guid) CurrentUser.Id);
if (!string.IsNullOrEmpty(token))
{
Alerts.Info($"Token received, validating token");
await ValidateToken(user, token);
return;
}
if (user.EmailConfirmed)
{
Alerts.Success("User email is already confirmed!");
return;
}
Alerts.Info("Creating a new email confirmation token to send to user");
var newToken = await _identityUserManager.GenerateEmailConfirmationTokenAsync(user);
var url = $"{Request.GetDisplayUrl()}?token={Uri.EscapeDataString(newToken)}";
Alerts.Info($"Navigate to this url to set mail to confirmed again: {url}");
}
catch (Exception exception)
{
Alerts.Danger(exception.Message);
}
}
private async Task ValidateToken(IdentityUser user, string token)
{
var result = await _identityUserManager.ConfirmEmailAsync(user, token);
if (result.Succeeded)
{
Alerts.Success("The token was verified!");
return;
}
foreach (var identityError in result.Errors ?? new List<IdentityError>())
{
Alerts.Danger($"Token validation error {identityError.Code}:{identityError.Description}");
}
}
}
} |
I have issues with CurrentUser not updating (#6335) which I still think is strange logic, was that the reason you could not reproduce perhaps? |
maliming
added a commit
that referenced
this issue
Jan 26, 2021
maliming
added a commit
that referenced
this issue
Feb 16, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Generally having the same problem as described in #2140.
When a user changes the name field in UI and click save (without changing their email) the value of EmailConfirmed is set to false. As a visitor I would not expect to need to re-confirm a mail that has not been modified.
Using Razor pages 4.1.
The text was updated successfully, but these errors were encountered: