public bool Login(string username, string password, string captcha) { if (username.Trim() == string.Empty) { throw new Exception("用户名不能为空!"); } if (password.Trim() == string.Empty) { throw new Exception("密码不能为空!"); } if (captcha.Trim() == string.Empty) { throw new Exception("验证码不能为空!"); } if (!VerCode.CheckCode("log", captcha)) { throw new Exception("验证码验证错误!"); } var su = SystemUser.Login(username, password); if (su != null) { HttpCookie cookie = new HttpCookie("login_Username", username) { Expires = DateTime.Now.AddYears(1) }; HttpContext.Current.Response.Cookies.Add(cookie); return(true); } else { return(false); } }
protected void Page_Load(object sender, EventArgs e) { if (string.IsNullOrEmpty(Request["vctype"])) { Response.End(); } VerCode.NewCode(Request["vctype"]); }
/// <summary> /// 发送图片给打码平台 /// </summary> /// <param name="path"></param> public string SendImage(string path) { string username = "******"; string pwd = "202063sbmP"; string softKey = "dragon8dama"; return(VerCode.RecYZM_A_2(path, 1303, 2, 6, username, pwd, softKey)); }
public string Recognize(string filePath) { if (string.IsNullOrWhiteSpace(this.Account.SoftKey)) { throw new Exception("请输入平台软件Key!"); } if (string.IsNullOrWhiteSpace(this.Account.UserName)) { throw new Exception("请输入平台普通用户账号!"); } if (string.IsNullOrWhiteSpace(this.Account.Password)) { throw new Exception("请输入平台密码!"); } var code = VerCode.RecYZM_A(filePath, Account.UserName, Account.Password, Account.SoftKey).Split('|').ToList(); var result = code[0]; return(result); }
/// <summary> /// 验证码验证 /// </summary> /// <param name="phone">手机号</param> /// <param name="code">验证码</param> /// <returns></returns> public static VerCode VerCode(string phone, string code) { VerCode verCode = new VerCode(); verCode.IsSuccess = false; using (ApplicationDbContext db = new ApplicationDbContext()) { var verifyCode = db.VerificationCodes.FirstOrDefault(s => s.To == phone && s.Code == code); if (verifyCode == null) { verCode.Message = "验证码有误"; } else if (verifyCode.CreateDate.AddMinutes(10) <= DateTime.Now) { verCode.Message = "验证码已过期"; } else { verCode.IsSuccess = true; } } return(verCode); }