mirror of
https://e.coding.net/circlecloud/CitySunlight.git
synced 2024-10-31 07:18:47 +00:00
Clean up...
This commit is contained in:
parent
2d7826865f
commit
72ad1272ab
@ -18,7 +18,6 @@ namespace CitySunlight
|
||||
{
|
||||
String html = "";
|
||||
if (Session["username"] == null)
|
||||
//html = "<li><a href=\"#\" data-toggle=\"modal\" data-target=\"#loginModal\" >登录</a></li>";
|
||||
html = "<li><a href=\"/Account/Login.aspx\" >登录</a></li>";
|
||||
else
|
||||
{
|
||||
@ -29,55 +28,5 @@ namespace CitySunlight
|
||||
}
|
||||
return html;
|
||||
}
|
||||
public String getAlert(String msg)
|
||||
{
|
||||
String html = "<div class=\"alert alert-{0} alert-dismissable\">";
|
||||
html += "<button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-hidden=\"true\">×</button>";
|
||||
html += "{1}</div>";
|
||||
return (msg == null || msg == "") ? "" : String.Format(html, "danger", msg);
|
||||
}
|
||||
|
||||
protected void login_Click(object sender, EventArgs e)
|
||||
{
|
||||
//String username = UserNameTx.Value;
|
||||
String password = HttpUtils.getElementsbyName("PassWordTx");
|
||||
String username = HttpUtils.getElementsbyName("UserNameTx");
|
||||
login(username, password);
|
||||
}
|
||||
public bool login(String username, String password)
|
||||
{
|
||||
if ((username == null) || (password == null))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ((username.Length == 0) || (password.Length == 0))
|
||||
{
|
||||
msg = "请填写完整的账号和密码!";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!UserManager.isExist(username))
|
||||
{
|
||||
msg = "当前用户不存在!";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (UserManager.GetTimes(username) > 2)
|
||||
{
|
||||
msg = "登录错误超过3次,已被锁定,请联系管理员!";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (UserManager.LoginUser(username, password))
|
||||
{
|
||||
Session["username"] = username;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = "账号密码错误,还可以尝试" + (4 - UserManager.GetTimes(username)) + "次..!";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user