public async Task <ActionResult> CheckTwoFactor(AuthenticateModel data) { if (!_twoFactorVerificationSettings.UseVerification) { return(Json(new TwoFactorInfo { UseVerification = false })); } try { var webSignature = await GoogleJsonWebSignatureEx.ValidateAsync(data.GoogleSignInIdToken); var checkError = CheckWebSignature(webSignature); if (checkError != null) { return(checkError); } string email = webSignature.Email; TwoFactorInfoModel twoFactorInfo = await _backofficeMembershipClient.CheckTwoFactorAsync( new CheckTwoFactorModel() { UserId = email, Ip = this.GetIp() }); if (twoFactorInfo.Result == CheckTwoFactorResult.UserNotRegistered) { _log.Info($"User {email} is not registered."); return(this.JsonFailResult(Phrases.UserNotRegistered, "#googleSignIn")); } if (twoFactorInfo.Result == CheckTwoFactorResult.UserIsDisabled) { _log.Info($"User {email} is disabled"); return(this.JsonFailResult(Phrases.UserIsDisabled, "#googleSignIn")); } if (twoFactorInfo.Result == CheckTwoFactorResult.SkipVerification) { return(Json(new TwoFactorInfo { UseVerification = false })); } return(Json(new TwoFactorInfo { UseVerification = true, ExistCode = twoFactorInfo.ExistCode, ImageUrl = twoFactorInfo.ImageUrl, TextKey = twoFactorInfo.TextKey })); } catch (InvalidJwtException ex) { _log.Info($"Invalid Jwt: {ex}"); return(this.JsonFailResult(Phrases.InvalidJwt, "#googleSignIn")); } }