RoadFlow2.1 临时演示

Login1.aspx.cs 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. namespace WebForm
  8. {
  9. public partial class Login1 : WebForm.Common.BasePage
  10. {
  11. protected string Script = string.Empty;
  12. protected void Page_Load(object sender, EventArgs e)
  13. {
  14. if (IsPostBack)
  15. {
  16. check();
  17. }
  18. }
  19. protected override bool CheckApp()
  20. {
  21. return true;
  22. }
  23. protected override bool CheckUrl(bool isEnd = true)
  24. {
  25. return true;
  26. }
  27. protected override bool CheckLogin(bool isRedirect = true)
  28. {
  29. return true;
  30. }
  31. private void check()
  32. {
  33. string isVcodeSessionKey = RoadFlow.Utility.Keys.SessionKeys.IsValidateCode.ToString();
  34. string vcodeSessionKey = RoadFlow.Utility.Keys.SessionKeys.ValidateCode.ToString();
  35. string account = Request.Form["Account"];
  36. string password = Request.Form["Password"];
  37. string force = Request.Form["Force"];
  38. string vcode = Request.Form["VCode"];
  39. bool isSessionLost = "1" == Request.QueryString["session"];//是否是超时后再登录
  40. if (Session[isVcodeSessionKey] != null
  41. && "1" == Session[isVcodeSessionKey].ToString()
  42. && (Session[vcodeSessionKey] == null
  43. || string.Compare(Session[vcodeSessionKey].ToString(), vcode.Trim(), true) != 0))
  44. {
  45. Page.ClientScript.RegisterStartupScript(Page.GetType(), "error", "alert('验证码错误!');", true);
  46. }
  47. else if (account.IsNullOrEmpty() || password.IsNullOrEmpty())
  48. {
  49. Session[isVcodeSessionKey] = "1";
  50. RoadFlow.Platform.Log.Add("用户登录失败", string.Concat("用户:", account, "登录失败,帐号或密码为空"), RoadFlow.Platform.Log.Types.用户登录);
  51. Script = "alert('帐号或密码不能为空!');";
  52. }
  53. else
  54. {
  55. RoadFlow.Platform.Users busers = new RoadFlow.Platform.Users();
  56. var user = busers.GetByAccount(account.Trim());
  57. if (user == null || string.Compare(user.Password, busers.GetUserEncryptionPassword(user.ID.ToString(), password.Trim()), false) != 0)
  58. {
  59. Session[isVcodeSessionKey] = "1";
  60. RoadFlow.Platform.Log.Add("用户登录失败", string.Concat("用户:", account, "登录失败,帐号或密码错误"), RoadFlow.Platform.Log.Types.用户登录);
  61. Script = "alert('帐号或密码错误!');";
  62. }
  63. else if (user.Status == 1)
  64. {
  65. Session[isVcodeSessionKey] = "1";
  66. RoadFlow.Platform.Log.Add("用户登录失败", string.Concat("用户:", account, "登录失败,帐号已被冻结"), RoadFlow.Platform.Log.Types.用户登录);
  67. Script = "alert('帐号已被冻结!');";
  68. }
  69. else
  70. {
  71. //RoadFlow.Platform.OnlineUsers bou = new RoadFlow.Platform.OnlineUsers();
  72. //var onUser = bou.Get(user.ID);
  73. //if (onUser != null && "1" != force)
  74. //{
  75. // string ip = onUser.IP;
  76. // Session.Remove(isVcodeSessionKey);
  77. // Script = "if(confirm('当前帐号已经在" + ip + "登录,您要强行登录吗?')){$('#Account').val('" + account + "');$('#Password').val('" + password + "');$('#Force').val('1');$('#form1').submit();}";
  78. //}
  79. //else
  80. //{
  81. Guid uniqueID = Guid.NewGuid();
  82. Session[RoadFlow.Utility.Keys.SessionKeys.UserID.ToString()] = user.ID;
  83. Session[RoadFlow.Utility.Keys.SessionKeys.UserUniqueID.ToString()] = uniqueID;
  84. //bou.Add(user, uniqueID);
  85. Session.Remove(isVcodeSessionKey);
  86. RoadFlow.Platform.Log.Add("用户登录成功", string.Concat("用户:", user.Name, "(", user.ID, ")登录成功"), RoadFlow.Platform.Log.Types.用户登录);
  87. if (isSessionLost)
  88. {
  89. Script = "alert('登录成功!');new RoadUI.Window().close();";
  90. }
  91. else
  92. {
  93. Script = "top.location='" + Common.Tools.BaseUrl + "Default.aspx';";
  94. }
  95. //}
  96. }
  97. }
  98. }
  99. }
  100. }