Base solution for your next web application
Open Closed

e-mail activation: cannot login #6293


User avatar
0
alexanderpilhar created

Version: 6.5.0, Asp.Net Core & Angular

Hi! Currently, I'm facing problems with the activation-code sent via e-mail being invalid (for both tenant- and user-registration). This is the case for my own project hosted in Azure as well as for the demo provided by ASPNETZERO (user-registration).

Is there something wrong with e-mail-activation?


7 Answer(s)
  • User Avatar
    0
    ryancyq created
    Support Team

    Hi can you share the server/client error log for your project?

    Also the steps you did when activating the email on demo.aspnetzero.com ?

  • User Avatar
    0
    alexanderpilhar created

    Hi @ryancyq!

    Here some are screenshots from demo:

  • User Avatar
    0
    alexanderpilhar created

    In database I can see the following:

    After creating a new user:

    • EmailConfirmationCode: [confirmation-code]
    • IsActive: 0
    • IsEmailConfirmed: 0

    After clicking the activation-code in e-mail:

    • EmailConfirmationCode: NULL
    • IsActive: 0
    • IsEmailConfirmed: 1

    I think the problem here is that IsActive is still false. AccountAppService.ActivateEmail() does not set IsActive to true. But I'm not sure if that is on purpose.

  • User Avatar
    0
    alexanderpilhar created

    Actually, I really think the problem is AccountAppService.ActivateEmail() not setting User.IsActive to true.

    Here's the code of current version (6.5.0) (but it is the same down to 4.5.1, which is the earliest version i have):

    public async Task ActivateEmail(ActivateEmailInput input)
    {
        var user = await UserManager.GetUserByIdAsync(input.UserId);
        if (user == null || user.EmailConfirmationCode.IsNullOrEmpty() || user.EmailConfirmationCode != input.ConfirmationCode)
        {
            throw new UserFriendlyException(L("InvalidEmailConfirmationCode"), L("InvalidEmailConfirmationCode_Detail"));
        }
    
        user.IsEmailConfirmed = true;
        user.EmailConfirmationCode = null;
    
        await UserManager.UpdateAsync(user);
    }
    

    Is there any reason to not set User.IsActive to true?

  • User Avatar
    0
    aaron created
    Support Team

    User.IsActive being false means the admin disabled the account.

    It is inappropriate for a user action to enable one's own account.

  • User Avatar
    0
    alexanderpilhar created

    Hi @aaron!

    Yes, that makes perfect sense, obviously!

    Shame on me :D

  • User Avatar
    0
    alexanderpilhar created

    But maybe it would make more sense to call it 'Disabled' on the UI !? I think that would better reflect it's purpose.