Example #1
0
        public async Task <IActionResult> UpdatePassword(
            [FromBody] NewPasswordDto newPasswordDto,
            [FromHeader(Name = "userId")] int userId)
        {
            var isOldPassCorrect =
                await _userDataService.CheckOldPasswordBeforeUpdateByUserIdAsync(userId,
                                                                                 newPasswordDto.OldPassword);

            if (isOldPassCorrect)
            {
                await _userDataUpdateService.UpdatePasswordByIdAsync(userId,
                                                                     newPasswordDto.NewPassword);

                return(Ok());
            }

            return(UnprocessableEntity("PREVIOUS PASSWORD IS NOT CORRECT"));
        }