public IActionResult ResetPassword(ResetPasswordViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            // var user = await _userManager.FindByEmailAsync(model.Email);

            var ad = adHelper.GetAllUsers();

            var user = ad.Find(x => x.Email.ToLower() == model.Email.ToLower());

            if (user == null || !PasswordCodeValid(model.Code, user.Username))
            {
                // Don't reveal that the user does not exist
                return(RedirectToAction(nameof(ResetPasswordConfirmation)));
            }

            var result = adHelper.EditPassword(user.Username, model.Password);//???

            if (result.Equals("OK"))
            {
                return(RedirectToAction(nameof(ResetPasswordConfirmation)));
            }
            //AddErrors(result);
            return(View());
        }
Example #2
0
        public IActionResult EditPassword(string oldpassword, string newpassword)
        {
            string username = User.Identity.Name;
            string code     = "";

            code = adHelper.EditPassword(username, newpassword);
            if (code == "OK")
            {
                TempData["data"] = "Succesfully changed!";
                return(Redirect("Index"));
            }
            else
            {
                TempData["data"] = "Wrong password!";
                return(View());
            }
        }