public async Task MustChangeUserPasswordAsync() { // Given var userId = "123YWZ"; var userAlreadyExists = UserBuilder.New().WithId(userId).Build(); var oldPasswordEncrypt = userAlreadyExists.Password; // When _userMocks.MockUserGetById(userAlreadyExists, userId); await _userChangePassword.UpdateAsync(userId, _userRegisterDto.Password, _userLog); // Then Assert.NotEqual(userAlreadyExists.Password, oldPasswordEncrypt); }
public async Task <IActionResult> PutAsync(string id, UserRegisterDto userRegisterDto) { var userLog = User.FindFirst(ClaimTypes.Name)?.Value; if (string.IsNullOrEmpty(userRegisterDto.Password)) { var user = await _userRegister.StoreAsync(id, userRegisterDto.Name, userRegisterDto.Email, null, userRegisterDto.Permission, userLog); var userDto = Mapper.Map <UserDto>(user); return(Ok(userDto)); } else { await _userChangePassword.UpdateAsync(id, userRegisterDto.Password, userLog); return(Ok()); } }