Exemplo n.º 1
0
        public async Task <IActionResult> ChangeUserPassword([FromRoute] string userId, [FromBody] ChangePasswordDto changePasswordDto)
        {
            if (userId != changePasswordDto.UserId)
            {
                throw new Exception("Id пользователя не совпадает");
            }
            if (!await _userManager.UserExistsAsync(userId))
            {
                return(BadRequest($"Такого пользователя НЕ существует {userId}"));
            }
            try
            {
                var res = await _userManager.ChangeUserPassword(userId, changePasswordDto.CurrentPassword, changePasswordDto.NewPassword);

                return(Ok(res));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(BadRequest(e.Message));
            }
        }