Пример #1
0
        public async Task <IActionResult> ChangePassword([FromBody] ChangePasswordModel changePasswordModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var user = await userManager.FindByIdAsync(User.FindFirst(ClaimTypes.NameIdentifier).Value);

            var result = await userManager.ChangePasswordAsync(
                user,
                changePasswordModel.OldPassword,
                changePasswordModel.NewPassword);

            return(Ok(new { success = result.Succeeded, message = result.Errors }));
        }