private async Task <bool> UpdateUser(CreateOrEditUserInput input) { try { var user = await UserManager.FindByIdAsync(input.Id); ObjectMapper.Map(input, user); var result = await UserManager.UpdateAsync(user); if (!input.RequestPasswordChange) { return(result.Succeeded); } var token = await UserManager.GeneratePasswordResetTokenAsync(user); var passwordChangeResult = await UserManager.ResetPasswordAsync(user, token, input.Password); return(passwordChangeResult.Succeeded && result.Succeeded); } catch (Exception e) { Logger.LogError(e.ToString()); throw; } }
public async Task LoadUser(string id) { IsEdit = !string.IsNullOrEmpty(id); Input = await UserService.GetUserForEdit(id); StateHasChanged(); }
private async Task <bool> CreateUser(CreateOrEditUserInput input) { var user = ObjectMapper.Map <CodeHubUser>(input); user.Id = Guid.NewGuid().ToString(); var result = await UserManager.CreateAsync(user, input.Password); return(result.Succeeded); }
public async Task <bool> CreateOrEditUser(CreateOrEditUserInput input) { if (string.IsNullOrEmpty(input.Id)) { return(await CreateUser(input)); } return(await UpdateUser(input)); }
public virtual async Task Create(CreateOrEditUserInput input) { await this._userManager.CreateAsync( input.EntityDto.UserName, input.Password, input.EntityDto.Nickname, input.EntityDto.PhoneNumber, input.EntityDto.PhoneNumberConfirmed, input.EntityDto.Email, input.EntityDto.EmailConfirmed, input.EntityDto.LockoutEnabled, input.EntityDto.IsActive, input.EntityDto.TwoFactorEnabled ); }
public virtual async Task Update(CreateOrEditUserInput input) { if (!input.EntityDto.Id.HasValue) { return; } await this._userManager.UpdateAsync( input.EntityDto.Id, input.Password, input.EntityDto.Nickname, input.EntityDto.PhoneNumber, input.EntityDto.PhoneNumberConfirmed, input.EntityDto.Email, input.EntityDto.EmailConfirmed, input.EntityDto.LockoutEnabled, input.EntityDto.IsActive, input.EntityDto.TwoFactorEnabled ); }