protected override void OnLoad(EventArgs e) { base.OnLoad(e); IsSignIn = Security.IsAuthenticated(); if (Html.IsPostBack) { InitParam(); if (Action == "login") { Authenticate(); } else if (Action == "logout") { Signout(); } } if (!String.IsNullOrEmpty(Request["Authenticator"]) && !String.IsNullOrEmpty(Request["accountID"])) { SSORequest ssoRequest = SSORequest.GetRequest(HttpContext.Current); string actID = ssoRequest.AccountID; if (Authentication.ValidateEACToken(ssoRequest) && !string.IsNullOrEmpty(actID) && We7Helper.IsGUID(actID)) { Security.SetAccountID(actID); IsSignIn = true; } } if (Security.IsAuthenticated()) { Response.Redirect(ReturnUrl); } }
protected void Page_Load(object sender, EventArgs e) { Response.Clear(); try { string action = Request["Action"] ?? "".ToLower(); switch (action) { case "signin": Signin(); break; case "logout": LogOut(); break; } } catch { } finally { SSORequest request = SSORequest.GetRequest(HttpContext.Current); if (String.IsNullOrEmpty(Request["ToUrls"])) { request.ToUrls = Request["ToUrls"]; request.AppUrl = Request["AppUrl"]; request.UserName = Request["UserName"]; request.Password = Request["Password"]; request.Action = Request["Action"]; } Authentication.PostChains(request); } }
/// <summary> /// 验证用户 /// </summary> void Authenticate() { if (String.Compare(LoginName, SiteConfigs.GetConfig().AdministratorName, false) == 0) { if (CDHelper.AdminPasswordIsValid(Password)) { Security.SetAccountID(We7Helper.EmptyGUID); UserName = SiteConfigs.GetConfig().AdministratorName; IsSignIn = true; } else { IsSignIn = false; Message = "密码错误"; } } else { if (Request["Authenticator"] != null && Request["accountID"] != null) { SSORequest ssoRequest = SSORequest.GetRequest(HttpContext.Current); string actID = ssoRequest.AccountID; if (Authentication.ValidateEACToken(ssoRequest) && !string.IsNullOrEmpty(actID) && We7Helper.IsGUID(actID)) { Security.SetAccountID(actID, IsPersist); UserName = ssoRequest.UserName; IsSignIn = true; } else if (Request["message"] != null) { Message = Request["message"]; IsSignIn = false; return; } } else { IAccountHelper AccountHelper = AccountFactory.CreateInstance(); string[] result = AccountHelper.Login(LoginName, Password); if (result[0] == "false") { Message = result[1]; IsSignIn = false; } else { IsSignIn = true; UserName = AccountHelper.GetAccount(result[1], new string[] { "LoginName" }).LoginName; Response.Redirect(ReturnUrl); } } } }
/// <summary> /// 验证用户 /// </summary> void Authenticate() { if (Request["Authenticator"] != null && Request["accountID"] != null) { SSORequest ssoRequest = SSORequest.GetRequest(HttpContext.Current); string actID = ssoRequest.AccountID; if (Authentication.ValidateEACToken(ssoRequest) && !string.IsNullOrEmpty(actID) && We7Helper.IsGUID(actID)) { Security.SetAccountID(actID); } else if (Request["message"] != null) { Message = Request["message"]; return; } } else { Session["$ActionFrom"] = Request.UrlReferrer.PathAndQuery; Session["$_ActionID"] = _ActionID; IAccountHelper AccountHelper = AccountFactory.CreateInstance(); string loginName = Name; //邮箱格式 if (Name.IndexOf('@') > -1) { Account account = AccountHelper.GetAccountByEmail(Name); if (account != null) { loginName = account.LoginName; } } string[] result = AccountHelper.Login(loginName, Password); if (result[0] == "false") { Message = result[1]; return; } else { Author = result[1]; } } if (!string.IsNullOrEmpty(ReturnUrl)) { Response.Redirect(ReturnUrl); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { GeneralConfigInfo si = GeneralConfigs.GetConfig(); if (si != null) { if (si.IsOEM) { CopyrightLiteral.Text = si.Copyright; } else { CopyrightLiteral.Text = si.CopyrightOfWe7; } } SiteConfigInfo sci = SiteConfigs.GetConfig(); if (sci == null) { Response.Write("对不起,您的系统已升级,但配置文件尚未升级,您需要对配置数据进行升级。现在升级吗?<a href='../install/upgradeconfig.aspx'><u>现在升级</u></a>"); Response.End(); } else { #if DEBUG LoginNameTextBox.Text = sci.AdministratorName; #endif GenerateRandomCode(); if (Request["action"] != null && Request["action"].ToString() == "logout" && Request["Authenticator"] == null) { //记录日志 string content = string.Format("退出站点"); AddLog("站点登录", content); string result = SignOut(); if (!string.IsNullOrEmpty(result)) { ShowMessage("登录退出没有成功!原因:" + result); } else { SSOLogout(); } } } } if (Request["user"] != null && Request["pass"] != null) { LoginAction(Request["user"].ToString(), Request["pass"].ToString()); } if (Request["Authenticator"] != null && Request["accountID"] != null) { SSORequest ssoRequest = SSORequest.GetRequest(HttpContext.Current); string actID = ssoRequest.AccountID; if (Authentication.ValidateEACToken(ssoRequest) && !string.IsNullOrEmpty(actID) && We7Helper.IsGUID(actID)) { Security.SetAccountID(actID); SSOLogin(ssoRequest.UserName, ssoRequest.Password); GoWhere(); } else if (Request["message"] != null) { ShowMessage("登录失败!原因:" + Request["message"]); return; } } }