diff --git a/北京北汽/SCP/default_hb.aspx.cs b/北京北汽/SCP/default_hb.aspx.cs index 18ed6cf..d6f38cd 100644 --- a/北京北汽/SCP/default_hb.aspx.cs +++ b/北京北汽/SCP/default_hb.aspx.cs @@ -117,11 +117,9 @@ namespace SCP } private void Login(string p_userName, string p_password) { - HttpCookie cookie_checkingcode = Request.Cookies["ImageV"]; if (string.IsNullOrEmpty(textUserName.Value) || string.IsNullOrEmpty(textPassword.Value)) { Alert.Show(GetResourceKey("用户名或密码不能为空!")); - cookie_checkingcode.Expires = DateTime.Now; img.ImageUrl = DrawToBase64(4); return; } @@ -129,14 +127,12 @@ namespace SCP if (string.IsNullOrEmpty(inputValue.Value)) { Alert.Show(GetResourceKey("验证码不能为空!")); - cookie_checkingcode.Expires = DateTime.Now; img.ImageUrl = DrawToBase64(4); return; } - if (inputValue.Value.Trim().ToLower() != (cookie_checkingcode.Value.ToLower().ToString())) + if (inputValue.Value.Trim().ToLower() != (Session["CheckCode"].ToString().ToLower())) { Alert.Show(GetResourceKey("验证码错误!")); - cookie_checkingcode.Expires = DateTime.Now; img.ImageUrl = DrawToBase64(4); return; } @@ -148,7 +144,6 @@ namespace SCP if (!user.Enabled) { Alert.Show(GetResourceKey("用户未启用,请联系管理员!")); - cookie_checkingcode.Expires = DateTime.Now; img.ImageUrl = DrawToBase64(4); return; } @@ -168,7 +163,6 @@ namespace SCP if (this.textPassword1.Value.Trim() != textConfim.Value.Trim()) { Alert.Show(GetResourceKey("新密码与确认密码不一致!")); - cookie_checkingcode.Expires = DateTime.Now; img.ImageUrl = DrawToBase64(4); return; } @@ -177,7 +171,6 @@ namespace SCP if (!Regex.IsMatch(this.textPassword1.Value.Trim(), pattern)) { Alert.Show(GetResourceKey("新密码必须包含大小写字母,英文特殊符号~!@#$%^&*_中的一个和数字且不能少于8位!")); - cookie_checkingcode.Expires = DateTime.Now; img.ImageUrl = DrawToBase64(4); return; @@ -189,7 +182,6 @@ namespace SCP else { Alert.Show(GetResourceKey("您的密码过于简单,请修改密码,新密码必须包含大小写字母,英文特殊符号~!@#$%^&*_中的一个和数字且不能少于8位!")); - cookie_checkingcode.Expires = DateTime.Now; img.ImageUrl = DrawToBase64(4); return; } @@ -202,15 +194,12 @@ namespace SCP string date = DateTime.Now.ToShortDateString(); var ret = SCP_LOGINNUMBER_CONTROLLER.Save_TA_LOGINNUMBER(p_userName, LoginNumer.Sussess, date); - // 成功就失效 - cookie_checkingcode.Expires = DateTime.Now; // 登录成功 LoginSuccess(user); } else { Alert.Show("不是选定工厂下供应商"); - cookie_checkingcode.Expires = DateTime.Now; img.ImageUrl = DrawToBase64(4); return; } @@ -229,7 +218,6 @@ namespace SCP { Alert.Show(GetResourceKey("用户名或密码错误!")); - cookie_checkingcode.Expires = DateTime.Now; img.ImageUrl = DrawToBase64(4); var number = SCP_LOGINNUMBER_CONTROLLER.GetlistUserNumber(p_userName); if (number != null) @@ -258,7 +246,6 @@ namespace SCP else { Alert.Show(GetResourceKey("用户名或密码错误!")); - cookie_checkingcode.Expires = DateTime.Now; img.ImageUrl = DrawToBase64(4); var number = SCP_LOGINNUMBER_CONTROLLER.GetlistUserNumber(p_userName); if (number != null) @@ -299,8 +286,9 @@ namespace SCP { roleIDs = String.Join(",", user.Roles.Select(r => r.ID).ToArray()); } + Session["CheckCode"] = null; bool isPersistent = true; - DateTime expiration = DateTime.Now.AddSeconds(double.Parse(ConfigurationManager.AppSettings["SCP_TIME_OUT"])); + DateTime expiration = DateTime.Now.AddMinutes(double.Parse(ConfigurationManager.AppSettings["SCP_TIME_OUT"])); CreateFormsAuthenticationTicket(user.Name, roleIDs, isPersistent, expiration, user.UsedDomain); var first = DB.Users.Where(p => p.Name == user.Name).FirstOrDefault(); if (first != null) @@ -465,8 +453,7 @@ namespace SCP public string DrawToBase64(int lengths) { string code = RandomVerificationCode(lengths); - HttpCookie a = new HttpCookie("ImageV", code); - Response.Cookies.Add(a); + Session["CheckCode"] = code; Bitmap png = DrawImage(code); string r = "data:image/jpg;base64," + BitmapToBase64Str(png); return r;