public async Task AccountVerifyCodePostSignsIn()
 {
     this.signInManangerMock.Setup(mock => mock.TwoFactorSignInAsyncWrap("EmailCode", It.IsAny<string>(), It.IsAny<bool>(), It.IsAny<bool>())).Returns(Task.FromResult(SignInStatus.Success));
     this.accountController.SignInManager = this.signInManangerMock.Object;
     var model = new VerifyCodeViewModel { Code = "somecode", ReturnUrl = string.Empty, Provider = "EmailCode", RememberBrowser = false };
     var result = await this.accountController.VerifyCode(model);
     result.Should().BeRedirectToRouteResult().WithAction("index").WithController("dashboard");
 }
 public async Task AccountVerifyCodePostLocked()
 {
     this.signInManangerMock.Setup(mock => mock.TwoFactorSignInAsyncWrap("EmailCode", It.IsAny<string>(), It.IsAny<bool>(), It.IsAny<bool>())).Returns(Task.FromResult(SignInStatus.LockedOut));
     this.accountController.SignInManager = this.signInManangerMock.Object;
     var model = new VerifyCodeViewModel { Code = "somecode", ReturnUrl = string.Empty, Provider = "EmailCode", RememberBrowser = false };
     var result = await this.accountController.VerifyCode(model);
     result.Should().BeViewResult().WithViewName("~/Features/Account/Lockout.cshtml");
 }
        public virtual async Task<ActionResult> VerifyCode(VerifyCodeViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return this.View(MVC.Account.Views.VerifyCode, model);
            }

            var result = await this.SignInManager.TwoFactorSignInAsyncWrap(model.Provider, model.Code, isPersistent: false, rememberBrowser: true); //model.RememberBrowser);
            switch (result)
            {
                case SignInStatus.Success:
                    if (!string.IsNullOrEmpty(model.ReturnUrl) && Url.IsLocalUrl(model.ReturnUrl))
                    {
                        return this.Redirect(model.ReturnUrl);
                    }

                    // Goes to dashboard or Login, if user is not logged in yet
                    return this.RedirectToAction(MVC.Dashboard.ActionNames.Index, MVC.Dashboard.Name);
                case SignInStatus.LockedOut:
                    return this.View(MVC.Account.Views.Lockout);
                case SignInStatus.Failure:
                default:
                    ModelState.AddModelError(string.Empty, "Invalid code");
                    return this.View(MVC.Account.Views.VerifyCode, model);
            }
        }