Exemple #1
0
        public async Task <JsonResult> ResetPassword(ResetPasswordVM ResetVM)
        {
            eCommerceContext context = new eCommerceContext();

            var UserManager = new UserManager <eCommerceUser>(new UserStore <eCommerceUser>(context));


            JsonResult jResult = new JsonResult();


            eCommerceUser user = await userApiService.GetUserById(ResetVM.UserId);

            if (user != null)
            {
                var result = await UserManager.ChangePasswordAsync(ResetVM.UserId, ResetVM.OldPassword, ResetVM.NewPassword);

                if (result.Succeeded)
                {
                    await userApiService.Save();

                    jResult.Data = new { Success = true, Messages = "Your password has been reset. Please login with your updated credentials now." };

                    return(jResult);
                }

                else
                {
                    jResult.Data = new { Success = false, Messages = "Unable to reset password." };
                }
            }



            return(jResult);
        }