예제 #1
0
        public ActionResult ChangeManagerPassword(string email)
        {
            ChangeManagerPasswordViewModel newcmpvm = new ChangeManagerPasswordViewModel();
            {
                newcmpvm.Email = email;

            };
            return View(newcmpvm);
        }
예제 #2
0
        public async Task<ActionResult> ChangeManagerPasswordAsync(ChangeManagerPasswordViewModel cmpvm)
        {
            AppUser dbUsers = _context.Users.Where(u => u.Email == cmpvm.Email).FirstOrDefault();

            if (ModelState.IsValid == false)
            {
                return View(cmpvm);
            }

            AppUser userLoggedIn = await _userManager.FindByNameAsync(User.Identity.Name);

            var removepassword = await _userManager.RemovePasswordAsync(dbUsers);
            var addpassword = await _userManager.AddPasswordAsync(dbUsers, cmpvm.NewManagerPassword);

            if (addpassword.Succeeded)
            {
                return RedirectToAction(nameof(IndexManager));
            }

            else
                return View("Error", new String[] { "There was a problem updating the manager's password!" });
        }