public virtual async Task <ActionResult> ForgotPassword(ForgotPasswordViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await CustomUser.FindByNameAsync(model.Email);

                if (user == null || !(await CustomUser.IsEmailConfirmedAsync(user.Id)))
                {
                    // Don't reveal that the user does not exist or is not confirmed
                    return(View("ForgotPasswordConfirmation"));
                }


                // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                // Send an email with this link
                string code = await CustomUser.GeneratePasswordResetTokenAsync(user.Id);

                var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                await CustomUser.SendEmailAsync(user.Id, "Reset Password", "Please reset your password by clicking <a href=\"" + callbackUrl + "\">here</a>");

                return(RedirectToAction("ForgotPasswordConfirmation", "Account"));
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
        public async virtual Task <ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            // var token = await CustomUser.GenerateTwoFactorTokenAsync("1024", "Phone Code");


            // ClaimsIdentity identity = new ClaimsIdentity(DefaultAuthenticationTypes.TwoFactorCookie);
            // identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, "1020"));
            // AuthenticationManager.SignIn(identity);

            //return RedirectToAction(Mvc.Account.VerifyCode("EmailTokenProvider", Url.Action(Mvc.Customers.Customer.Default()), false));

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            // This doesn't count login failures towards account lockout
            // To enable password failures to trigger account lockout, change to shouldLockout: true

            var user = await CustomUser.FindByNameAsync(model.Email.ToLower().Trim());

            if (user == null)
            {
                ModelState.AddModelError("", "Invalid login attempt.");
                return(View(model));
            }
            if (!await CustomUser.IsEmailConfirmedAsync(user.Id))
            {
                ModelState.AddModelError("", "You need to confirm your email.");
                return(View(model));
            }

            var result = await CustomSignIn.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout : false);

            switch (result)
            {
            case SignInStatus.Success:
                return(RedirectToLocal(returnUrl));

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

            case SignInStatus.RequiresVerification:
                return(RedirectToAction(Mvc.Account.VerifyCode("Phone Code", Url.Action(Mvc.Home.Index()), false)));

            case SignInStatus.Failure:
            default:
                ModelState.AddModelError("", "Invalid login attempt.");
                return(View(model));
            }
        }