Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "girish28892"

Question

here is my forgot password code

[HttpPost]
        //[DisableAuditing]
        [UnitOfWork]
        public async Task<ActionResult> ForgotPassword(ForgotPasswordViewModel vm)
        {
            if (ModelState.IsValid)
            {
                _unitOfWorkManager.Begin();
                _unitOfWorkManager.Current.SetFilterParameter(AbpDataFilters.MayHaveTenant, AbpDataFilters.Parameters.TenantId, 1);

                var user = await _userManager.FindByEmailAsync(vm.Email);

                //CurrentUnitOfWork.SetFilterParameter(AbpDataFilters.MayHaveTenant, AbpDataFilters.Parameters.TenantId, 1);
                if (user == null) // || !(await UserManager.IsEmailConfirmedAsync(user.Id)))
                {
                    // Don't reveal that the user does not exist or is not confirmed
                    ViewBag.IsValid = false;
                    return View("ForgotPasswordConfirmation");
                }
                var provider = new Microsoft.Owin.Security.DataProtection.DpapiDataProtectionProvider("ASP.NET IDENTITY");
                _userManager.UserTokenProvider = new DataProtectorTokenProvider<User, long>(provider.Create("ASP.NET Identity")) as
               IUserTokenProvider
               <User, long>;



                var code = await _userManager.GeneratePasswordResetTokenAsync(user.Id);
              
                var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                var body = "Please reset your password by clicking <a href=\"" + callbackUrl + "\">here</a>.";
                await _userManager.SendEmailAsync(user.Id, "Reset Password", "Please reset your password by clicking here: <a href=\"" + callbackUrl + "\">link</a>");
                bool emailStatus = Helpers.Utility.SendMail(vm.Email, "Estone - Reset Password", body);
                //ViewBag.Link = callbackUrl;
                ViewBag.IsValid = true;
                return View("ForgotPasswordConfirmation");
            }

            // If we got this far, something failed, redisplay form
            return View();
        }

and here is my reset password code

[HttpPost]
        [AllowAnonymous]
        [ValidateAntiForgeryToken]
        [DisableAuditing]
        [UnitOfWork]
        public async Task<ActionResult> ResetPassword(ResetPasswordViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return View(model);
            }
            _unitOfWorkManager.Begin();
            _unitOfWorkManager.Current.SetFilterParameter(AbpDataFilters.MayHaveTenant, AbpDataFilters.Parameters.TenantId, 1);
            var user = await _userManager.FindByEmailAsync(model.Email);
           
               
            if (user == null)
            {
                // Don't reveal that the user does not exist
                return RedirectToAction("ResetPasswordConfirmation", "Account");
            }
            var provider = new Microsoft.Owin.Security.DataProtection.DpapiDataProtectionProvider("ASP.NET IDENTITY");
            //var provider = Startup.DataProtectionProvider;
            _userManager.UserTokenProvider = new DataProtectorTokenProvider<User, long>(provider.Create("ASP.NET Identity")) as IUserTokenProvider<User, long>;

            var result = await _userManager.ResetPasswordAsync(user.Id, model.code, model.confirmPassword);


           await _unitOfWorkManager.Current.SaveChangesAsync();
         
         // unitOfWork.Complete();
          _unitOfWorkManager.Current.Completed +=(sender,args) => {

              _unitOfWorkManager.Current.SaveChangesAsync();
          };


            if (result.Succeeded)
            {
                return RedirectToAction("ResetPasswordConfirmation", "Account");
            }
            
            
            ModelState.AddModelError("", "Something wrong");
            
            return View("ResetPasswordConfirmation");
        }

both are working without any errors but still no change in password...pls help

Showing 1 to 1 of 1 entries