private void ValidateCaptcha() { if (webContext.AppConfig.LoginOptions.RequireCaptcha) { string requiredCode = HttpContext.Session.GetString(CaptchaSessionKey); if (string.IsNullOrEmpty(requiredCode) || string.IsNullOrEmpty(CaptchaCode) || !string.Equals(requiredCode, CaptchaCode.Trim(), StringComparison.OrdinalIgnoreCase)) { webContext.Log.WriteError(Locale.IsRussian ? "Указан неверный защитный код, IP {0}" : "Invalid captcha specified, IP {0}", HttpContext.Connection.RemoteIpAddress); ModelState.AddModelError(string.Empty, dict.InvalidCaptcha); ModelState.Remove(nameof(CaptchaCode)); CaptchaCode = ""; } } }
/// <summary> /// 提交验证码 /// </summary> /// <param name="state"></param> private async Task SubmitCaptchaCodeAsync() { if (string.IsNullOrWhiteSpace(CaptchaCode)) { return; } OfoApi.CurUser.TelPhone = TelPhone; var verifyCode = await OfoApi.GetVerifyCodeAsync(CaptchaCode.Trim(), VerifyId); if (await CheckOfoApiResult(verifyCode)) { ContentPageArgs args = new ContentPageArgs() { Name = "登录第二步", HeaderVisibility = Visibility.Collapsed, ContentElement = new LoginSecondStepContentView(), }; ContentNavigation(args); } }