|
@ -16,6 +16,8 @@ using CK.SCP.Common; |
|
|
using System.Configuration; |
|
|
using System.Configuration; |
|
|
using SCP.Code; |
|
|
using SCP.Code; |
|
|
using CK.SCP.Models.Enums; |
|
|
using CK.SCP.Models.Enums; |
|
|
|
|
|
using System.Drawing; |
|
|
|
|
|
|
|
|
namespace SCP |
|
|
namespace SCP |
|
|
{ |
|
|
{ |
|
|
public partial class default_hb : PageBase |
|
|
public partial class default_hb : PageBase |
|
@ -62,13 +64,14 @@ namespace SCP |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void LoadData() |
|
|
private void LoadData( int? a =0) |
|
|
{ |
|
|
{ |
|
|
// 如果用户已经登录,则重定向到管理首页
|
|
|
// 如果用户已经登录,则重定向到管理首页
|
|
|
if (User.Identity.IsAuthenticated) |
|
|
if (User.Identity.IsAuthenticated && a == 0) |
|
|
{ |
|
|
{ |
|
|
Response.Redirect(FormsAuthentication.DefaultUrl); |
|
|
Response.Redirect(FormsAuthentication.DefaultUrl); |
|
|
} |
|
|
} |
|
|
|
|
|
img.ImageUrl = DrawToBase64(4); |
|
|
} |
|
|
} |
|
|
protected string GetFactoryName() |
|
|
protected string GetFactoryName() |
|
|
{ |
|
|
{ |
|
@ -106,7 +109,6 @@ namespace SCP |
|
|
{ |
|
|
{ |
|
|
string userName = textUserName.Value.Trim(); |
|
|
string userName = textUserName.Value.Trim(); |
|
|
string password = textPassword.Value.Trim(); |
|
|
string password = textPassword.Value.Trim(); |
|
|
|
|
|
|
|
|
LoadResouce(); |
|
|
LoadResouce(); |
|
|
Login(userName, password); |
|
|
Login(userName, password); |
|
|
} |
|
|
} |
|
@ -115,11 +117,30 @@ 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); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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())) |
|
|
|
|
|
{ |
|
|
|
|
|
Alert.Show(GetResourceKey("验证码错误!")); |
|
|
|
|
|
cookie_checkingcode.Expires = DateTime.Now; |
|
|
|
|
|
img.ImageUrl = DrawToBase64(4); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
User user = DB.Users.Where(u => u.Name == p_userName).FirstOrDefault(); |
|
|
User user = DB.Users.Where(u => u.Name == p_userName).FirstOrDefault(); |
|
|
|
|
|
|
|
|
if (user != null) |
|
|
if (user != null) |
|
@ -127,6 +148,8 @@ namespace SCP |
|
|
if (!user.Enabled) |
|
|
if (!user.Enabled) |
|
|
{ |
|
|
{ |
|
|
Alert.Show(GetResourceKey("用户未启用,请联系管理员!")); |
|
|
Alert.Show(GetResourceKey("用户未启用,请联系管理员!")); |
|
|
|
|
|
cookie_checkingcode.Expires = DateTime.Now; |
|
|
|
|
|
img.ImageUrl = DrawToBase64(4); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
if (PasswordUtil.ComparePasswords(user.Password, p_password)) |
|
|
if (PasswordUtil.ComparePasswords(user.Password, p_password)) |
|
@ -134,7 +157,6 @@ namespace SCP |
|
|
|
|
|
|
|
|
String pattern = "(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[~!@#$%^&*_.]).{8,}"; |
|
|
String pattern = "(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[~!@#$%^&*_.]).{8,}"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!Regex.IsMatch(p_password, pattern)) |
|
|
if (!Regex.IsMatch(p_password, pattern)) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
@ -146,6 +168,8 @@ 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); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
@ -153,6 +177,8 @@ 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); |
|
|
return; |
|
|
return; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
@ -163,6 +189,8 @@ namespace SCP |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
Alert.Show(GetResourceKey("您的密码过于简单,请修改密码,新密码必须包含大小写字母,英文特殊符号~!@#$%^&*_中的一个和数字且不能少于8位!")); |
|
|
Alert.Show(GetResourceKey("您的密码过于简单,请修改密码,新密码必须包含大小写字母,英文特殊符号~!@#$%^&*_中的一个和数字且不能少于8位!")); |
|
|
|
|
|
cookie_checkingcode.Expires = DateTime.Now; |
|
|
|
|
|
img.ImageUrl = DrawToBase64(4); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -173,12 +201,17 @@ 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); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
return; |
|
|
return; |
|
@ -194,13 +227,16 @@ namespace SCP |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
Alert.Show(GetResourceKey("用户名或密码错误!")); |
|
|
Alert.Show(GetResourceKey("用户名或密码错误!")); |
|
|
|
|
|
cookie_checkingcode.Expires = DateTime.Now; |
|
|
|
|
|
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) |
|
|
{ |
|
|
{ |
|
|
if (number.Number < 5) |
|
|
if (number.Number < 5) |
|
|
{ |
|
|
{ |
|
|
Text2.Value = "密码错误" + number.Number + "次24小时内错误5次账号将变为未启用状态!"; |
|
|
Text2.Value = "用户名或密码错误" + number.Number + "次24小时内错误5次账号将变为未启用状态!"; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -222,12 +258,14 @@ namespace SCP |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
Alert.Show(GetResourceKey("用户名或密码错误!")); |
|
|
Alert.Show(GetResourceKey("用户名或密码错误!")); |
|
|
|
|
|
cookie_checkingcode.Expires = DateTime.Now; |
|
|
|
|
|
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) |
|
|
{ |
|
|
{ |
|
|
if (number.Number < 5) |
|
|
if (number.Number < 5) |
|
|
{ |
|
|
{ |
|
|
Text2.Value = "密码错误" + number.Number + "次24小时内错误五次账号将变为未启用状态!"; |
|
|
Text2.Value = "用户名或密码错误" + number.Number + "次24小时内错误五次账号将变为未启用状态!"; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -262,16 +300,15 @@ namespace SCP |
|
|
roleIDs = String.Join(",", user.Roles.Select(r => r.ID).ToArray()); |
|
|
roleIDs = String.Join(",", user.Roles.Select(r => r.ID).ToArray()); |
|
|
} |
|
|
} |
|
|
bool isPersistent = true; |
|
|
bool isPersistent = true; |
|
|
DateTime expiration = DateTime.Now.AddMinutes(double.Parse(ConfigurationManager.AppSettings["SCP_TIME_OUT"])); |
|
|
DateTime expiration = DateTime.Now.AddSeconds(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) |
|
|
{ |
|
|
{ |
|
|
first.Remark = user.UsedDomain; |
|
|
first.Remark = user.UsedDomain; |
|
|
DB.SaveChanges(); |
|
|
DB.SaveChanges(); |
|
|
} |
|
|
} |
|
|
|
|
|
img.ImageUrl = DrawToBase64(4); |
|
|
// 重定向到登陆后首页
|
|
|
// 重定向到登陆后首页
|
|
|
Response.Redirect(FormsAuthentication.DefaultUrl); |
|
|
Response.Redirect(FormsAuthentication.DefaultUrl); |
|
|
} |
|
|
} |
|
@ -418,6 +455,36 @@ namespace SCP |
|
|
btn_pass.Attributes["value"] = "Forgot Password"; |
|
|
btn_pass.Attributes["value"] = "Forgot Password"; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#region
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 返回参数
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="lengths"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public string DrawToBase64(int lengths) |
|
|
|
|
|
{ |
|
|
|
|
|
string code = RandomVerificationCode(lengths); |
|
|
|
|
|
HttpCookie a = new HttpCookie("ImageV", code); |
|
|
|
|
|
Response.Cookies.Add(a); |
|
|
|
|
|
Bitmap png = DrawImage(code); |
|
|
|
|
|
string r = "data:image/jpg;base64," + BitmapToBase64Str(png); |
|
|
|
|
|
return r; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 刷新验证码
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
|
protected void btnRefresh_Click(object sender, EventArgs e) |
|
|
|
|
|
{ |
|
|
|
|
|
LoadData(1); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|