public async Task <JsonResult> VerifySecurityCode(VerifySecurityCodeViewModel model) { model.ReturnUrl = NormalizeReturnUrl(model.ReturnUrl); CheckCurrentTenant(await _signInManager.GetVerifiedTenantIdAsync()); var result = await _signInManager.TwoFactorSignInAsync( model.Provider, model.Code, model.RememberMe, await IsRememberBrowserEnabledAsync() && model.RememberBrowser ); if (result.Succeeded) { return(Json(new AjaxResponse { TargetUrl = model.ReturnUrl })); } if (result.IsLockedOut) { throw new UserFriendlyException(L("UserLockedOutMessage")); } throw new UserFriendlyException(L("InvalidSecurityCode")); }
public async Task <JsonResult> VerifySecurityCode(VerifySecurityCodeViewModel model) { model.ReturnUrl = NormalizeReturnUrl(model.ReturnUrl); var tenantId = await _signInManager.GetVerifiedTenantIdAsync(); using (CurrentUnitOfWork.SetTenantId(tenantId)) { var result = await _signInManager.TwoFactorSignInAsync( model.Provider, model.Code, isPersistent : model.RememberMe, rememberBrowser : model.RememberBrowser ); switch (result) { case SignInStatus.Success: return(Json(new AjaxResponse { TargetUrl = model.ReturnUrl })); case SignInStatus.LockedOut: throw new UserFriendlyException(L("UserLockedOutMessage")); case SignInStatus.Failure: default: throw new UserFriendlyException(L("InvalidSecurityCode")); } } }