public ActionResult Login(string username, string password, string verifycode) { if (!VerifyCodeHelper.CheckVerifyCode(verifycode, this.CookieContext.VerifyCodeGuid)) { ModelState.AddModelError("error", "验证码错误"); return(View()); } var loginInfo = this.AccountService.Login(username, password); if (loginInfo != null) { this.CookieContext.UserToken = loginInfo.LoginToken; this.CookieContext.UserName = loginInfo.LoginName; this.CookieContext.UserId = loginInfo.UserID; var temp = RedirectToAction("Index", "Auth", new { Area = "Account" }); return(temp); } else { ModelState.AddModelError("error", "用户名或密码错误"); return(View()); } }
public JsonResult Check(string code) { if (string.IsNullOrEmpty(code)) { return(new JsonResult() { JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = new { msg = "请输入验证码" } }); } string msg = ""; if (VerifyCodeHelper.CheckCode(code)) { msg = "验证成功"; } else { msg = "验证失败"; } return(new JsonResult() { JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = new { msg = msg } }); }
protected void Page_Load(object sender, EventArgs e) { VerifyCodeHelper.GenerateImgCode(4); }
public FileContentResult GetVerifyCode() { return(File(VerifyCodeHelper.Create(), @"image/jpeg")); }
public ActionResult VerifyCode() { return(File(VerifyCodeHelper.GetVerifyCode(), @"image/Gif")); }
public FileContentResult VerifyCode() { return(File(VerifyCodeHelper.GetVerifyCode(), @"image/Gif")); }
public VerifyCodeHelperTests() { _helper = ServiceProvider.GetService <VerifyCodeHelper>(); }
/// <summary> /// 验证图片验证码 /// </summary> /// <param name="httpRequest"></param> public static void VerifyImageCode(this HttpRequest httpRequest) { httpRequest.Headers.TryGetValue("X-VGuid", out var guid); httpRequest.Headers.TryGetValue("X-VCode", out var code); VerifyCodeHelper.VerifyImageCode(guid, code); }