private void GenerateRandomCode() { if (CDHelper.Config.EnableLoginAuhenCode == "true") { tbAuthCode2.Visible = true; Response.Cookies["AreYouHuman"].Value = CaptchaImage.GenerateRandomCode(); } }
protected void Page_Load(object sender, EventArgs e) { CaptchaImage ci = new CaptchaImage(Request.Cookies["AreYouHuman"].Value, 120, 30, "黑体"); this.Response.Clear(); this.Response.ContentType = "image/jpeg"; ci.Image.Save(this.Response.OutputStream, ImageFormat.Jpeg); ci.Dispose(); }
/// <summary> /// 原始登录的方法 /// </summary> /// <param name="loginName">本地用户名</param> /// <param name="password">本地用户的密码</param> /// <param name="checkPassword">是否校验密码</param> void LoginAction(string loginName, string password) { if (String.IsNullOrEmpty(loginName) || String.IsNullOrEmpty(loginName.Trim())) { ShowMessage("错误:用户名不能为空!"); return; } if (String.IsNullOrEmpty(password) || String.IsNullOrEmpty(password.Trim())) { ShowMessage("错误:密码不能为空!"); return; } if (GeneralConfigs.GetConfig().EnableLoginAuhenCode == "true" && this.CodeNumberTextBox.Text != Request.Cookies["AreYouHuman"].Value) { ShowMessage("错误:您输入的验证码不正确,请重新输入!"); this.CodeNumberTextBox.Text = ""; Response.Cookies["AreYouHuman"].Value = CaptchaImage.GenerateRandomCode(); return; } bool loginSuccess = false; if (CheckLocalAdministrator(loginName)) { if (CDHelper.AdminPasswordIsValid(password)) { Security.SetAccountID(We7Helper.EmptyGUID); loginSuccess = true; SSOLogin(loginName, password); } else { ShowMessage("无法登录,原因:密码错误!"); return; } } else { string[] result = AccountHelper.Login(loginName, password); if (result[0] == "false") { ShowMessage("无法登录,原因:" + result[1]); return; } else { SSOLogin(loginName, password); } } GoWhere(); }
protected void Page_Load(object sender, System.EventArgs e) { // Create a CAPTCHA image using the text stored in the Session object. CaptchaImage ci = new CaptchaImage(Request.Cookies["AreYouHuman"].Value, 200, 50, "ΊΪΜε"); // Change the response headers to output a JPEG image. this.Response.Clear(); this.Response.ContentType = "image/jpeg"; // Write the image to the response stream in JPEG format. ci.Image.Save(this.Response.OutputStream, ImageFormat.Jpeg); // Dispose of the CAPTCHA image object. ci.Dispose(); }