public async Task <UserAccount> WriteUserAccountAsync( UserAccount userAccount) { var now = DateTime.UtcNow; userAccount.CreatedAt = now; userAccount.UpdatedAt = now; var userAccount2 = await userAccountStore .WriteAsync(userAccount); await eventService.RaiseSuccessfulUserAccountCreatedEventAsync( userAccount.Id, IdentityServerConstants.LocalIdentityProvider); return(userAccount2); }
public async Task <UserAccount> CreateNewLocalUserAccountAsync(string email, string password, string returnUrl = null) { var now = DateTime.UtcNow; var userAccount = new UserAccount { Id = Guid.NewGuid(), Email = email, PasswordHash = _crypto.HashPassword(password, _applicationOptions.PasswordHashingIterationCount), FailedLoginCount = 0, IsEmailVerified = false, IsLoginAllowed = _applicationOptions.RequireLocalAccountVerification, PasswordChangedAt = now, CreatedAt = now, UpdatedAt = now }; if (_applicationOptions.RequireLocalAccountVerification && !String.IsNullOrWhiteSpace(returnUrl)) { // Set verification key userAccount.SetVerification( _crypto.Hash(_crypto.GenerateSalt()).StripUglyBase64(), VerificationKeyPurpose.ConfirmAccount, returnUrl, now); } await _userAccountStore.WriteAsync(userAccount); // Emit event await _eventService.RaiseSuccessfulUserAccountCreatedEventAsync( userAccount.Id, IdentityServerConstants.LocalIdentityProvider); return(userAccount); }