Example #1
0
    public override async Task <IdentityResult> CreateAsync(FantasyCriticUser user, string password)
    {
        var existingAccountWithEmail = await _userStore.FindByEmailAsync(user.Email, CancellationToken.None);

        if (existingAccountWithEmail is not null)
        {
            return(IdentityResult.Failed(new IdentityError()
            {
                Code = "Email Taken", Description = "An account with that email address already exists."
            }));
        }

        int openUserNumber = await _userStore.GetOpenDisplayNumber(user.UserName);

        var now      = _clock.GetCurrentInstant();
        var fullUser = new FantasyCriticUser(user.Id, user.UserName, null, openUserNumber, user.Email,
                                             user.NormalizedEmail, user.EmailConfirmed, Guid.NewGuid().ToString(), user.PasswordHash, user.TwoFactorEnabled, user.AuthenticatorKey, now, false);
        var createdUser = await base.CreateAsync(fullUser, password);

        return(createdUser);
    }
 public Task <int> GetOpenDisplayNumber(string displayName)
 {
     return(_userStore.GetOpenDisplayNumber(displayName));
 }