Пример #1
0
        public ActionResult EmployeeChangePassword(string username)
        {
            EmployeeChangePasswordViewModel employee = new EmployeeChangePasswordViewModel
            {
                LoggedUser    = CurrentUser,    //BaseViewModel
                LoggedCompany = CurrentCompany, //BaseViewModel
                LogoUrl       = CurrentLogoUrl, //BaseViewModel

                Username = username
            };

            return(View(employee));
        }
Пример #2
0
        public async Task <ActionResult> EmployeeChangePassword(EmployeeChangePasswordViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await EmployeeManager.Users.FirstOrDefaultAsync(u => u.UserName == model.Username);

                var token = await EmployeeManager.GeneratePasswordResetTokenAsync(user.Id);

                var result = await EmployeeManager.ResetPasswordAsync(user.Id, token, model.Password);

                if (result == IdentityResult.Success)
                {
                    return(RedirectToAction("Index", "Admin", new { message = "Employee password updated successfully." }));
                }
            }

            return(View(model));
        }