public virtual async Task <ActionResult> ChangePassword(ChangePasswordViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var result = await UserManager.ChangePasswordAsync(User.Identity.GetUserId(), model.OldPassword, model.NewPassword);

            if (result.Succeeded)
            {
                var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());

                if (user != null)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);
                }
                if (user.MustChangePassword == true)
                {
                    user.MustChangePassword      = false;
                    user.LastPasswordChangedDate = DateTime.Now;
                    UserManager.UpdateGebruiker(user);
                }
                return(RedirectToAction("Index", "Manage", new { Message = ManageMessageId.ChangePasswordSuccess }));
            }
            AddErrors(result);
            return(View(model));
        }
        public virtual async Task <ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var user = await UserManager.FindByNameAsync(model.Email);

            if (user != null)
            {
                if (user.LastPasswordChangedDate.AddMonths(6) < DateTime.Now && user.Rol != RolType.Admin)
                {
                    //mgr.BlockKlant(user.GebruikerId);
                    user.MustChangePassword = true;
                    UserManager.UpdateGebruiker(user);
                    mgr.BlockKlant(user.GebruikerId);
                    ModelState.AddModelError("", "Uw passwoord is expired. Contacteer uw admin.");
                    return(View("Login"));
                }
                if (user.LastPasswordChangedDate.AddDays(7) < DateTime.Now && user.Rol != RolType.Admin)
                {
                    //mgr.BlockKlant(user.GebruikerId);
                    ViewBag.Melding = "Passwoord vervalt binnen 7 dagen!";
                    return(View(model));
                }
                if (user.Toegestaan == false)
                {
                    ModelState.AddModelError("", "Uw account is geblokkeerd. Contacteer uw admin.");
                    return(View("Login"));
                }
                var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout : false);

                switch (result)
                {
                case SignInStatus.Success:

                    if (user.Rol == RolType.KlantAccount)
                    {
                        if (user.MustChangePassword == true)
                        {
                            returnUrl = "~/Manage/ChangePassword";
                            return(RedirectToLocal(returnUrl));
                        }
                        else
                        {
                            returnUrl = "~/Home/Index";
                            return(RedirectToLocal(returnUrl));
                        }
                    }
                    if (user.Rol == RolType.Admin)
                    {
                        if (user.MustChangePassword == true)
                        {
                            returnUrl = "~/Manage/ChangePassword";
                            return(RedirectToLocal(returnUrl));
                        }
                        else
                        {
                            returnUrl = "~/Admin/Index";
                            return(RedirectToLocal(returnUrl));
                        }
                    }
                    if (user.MustChangePassword == true)
                    {
                        returnUrl = "~/Manage/ChangePassword";
                        return(RedirectToLocal(returnUrl));
                    }
                    else
                    {
                        returnUrl = "~/Klant/Home";
                        return(RedirectToLocal(returnUrl));
                    }

                case SignInStatus.LockedOut:
                    return(View("Lockout"));

                case SignInStatus.RequiresVerification:
                    return(RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe }));

                case SignInStatus.Failure:

                default:
                    ModelState.AddModelError("", "Ongeldige Login Gegevens.");
                    return(View(model));
                }
            }
            ModelState.AddModelError("", "Ongeldige inlog gegevens");
            // TempData["Melding"] = "Passwoord vervalt binnen 7 dagen!";
            return(View(model));
        }