Browse Source

北汽闪退

master
钱峰 2 years ago
parent
commit
88e08eba46
  1. 21
      北京北汽/SCP/default_hb.aspx.cs

21
北京北汽/SCP/default_hb.aspx.cs

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

Loading…
Cancel
Save