public async Task <IActionResult> GetUser(int id) { var userDetailsFromRepo = await _repo.GetUser(id); if (userDetailsFromRepo == null) { return(NotFound("User not Found")); } var userDetailsToShow = _mapper.Map <UserForDisplayDetailDto>(userDetailsFromRepo); return(Ok(userDetailsToShow)); }
public async Task <IActionResult> PasswordChange(int id, PasswordChangeDto passwordChangeDto) { if (id != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value)) { return(Unauthorized("Not authorized")); } var userFromRepo = await _repo.GetUser(id); userFromRepo.PasswordHash = _userManager.PasswordHasher .HashPassword(userFromRepo, passwordChangeDto.Password); var result = await _userManager.UpdateAsync(userFromRepo); if (!result.Succeeded) { return(BadRequest("Could Not Change Password")); } await _repo.SaveAll(); return(Ok(new{ message = "Updated Successfully" })); //imp }