private void Page_Load(object sender, System.EventArgs e) { #if DEBUG bDebug = true; #endif if (!IsPostBack) { if (imgCompanyLogo != null) { // 04/16/2006 Paul. Company logo can be customized. if (!Sql.IsEmptyString(Application["CONFIG.header_logo_image"])) { imgCompanyLogo.ImageUrl = Sql.ToString(Application["imageURL"]) + Sql.ToString(Application["CONFIG.header_logo_image"]); if (Sql.ToInteger(Application["CONFIG.header_logo_width"]) > 0) { imgCompanyLogo.Width = Sql.ToInteger(Application["CONFIG.header_logo_width"]); } if (Sql.ToInteger(Application["CONFIG.header_logo_height"]) > 0) { imgCompanyLogo.Height = Sql.ToInteger(Application["CONFIG.header_logo_height"]); } if (!Sql.IsEmptyString(Application["CONFIG.header_logo_style"])) { imgCompanyLogo.Attributes.Add("style", Sql.ToString(Application["CONFIG.header_logo_style"])); } imgCompanyLogo.AlternateText = L10n.Term(".COMPANY_LOGO"); } else { imgCompanyLogo.ImageUrl = Sql.ToString(Application["imageURL"]) + "SplendidCRM_Logo.gif"; imgCompanyLogo.Width = 207; imgCompanyLogo.Height = 60; imgCompanyLogo.AlternateText = L10n.Term(".COMPANY_LOGO"); } } } if (!IsPostBack) { try { // http://www.i18nguy.com/temp/rtl.html if (htmlRoot != null) { if (L10n.IsLanguageRTL()) { htmlRoot.Attributes.Add("dir", "rtl"); } } } catch { } } }
//protected HiddenField hiddenOpenId; //protected HiddenField hiddenAccessToken; //protected HiddenField hiddenNickname; //public bool IsQQLogin { get; set; } protected void Page_Command(Object sender, CommandEventArgs e) { if (e.CommandName == "Login") { trForgotError.Visible = false; lblForgotError.Text = String.Empty; if (Page.IsValid) { bool bValidUser = false; try { //windows集成登录(开发环境) if (Security.IsWindowsAuthentication()) { bValidUser = true; } else { //检查用户名和密码是否为空 if (txtUSER_NAME.Text.Trim().Length == 0 || txtPASSWORD.Text.Trim().Length == 0) { this.lblError.Text = "提示:请输入用户名和密码。"; return; } else//看看是否具有角色或者管理员 { //是否有效用户 //bool IsValidRight = false; //禁止没有角色的用户 //SqlProcs.spTaoqi_CheckUserHaveRoleOrAdmin(txtUSER_NAME.Text.Trim(), ref IsValidRight); /* if (!IsValidRight) { this.lblError.Text = "提示:您没有访问权限,请联系管理员!"; return; }*/ } } // 02/20/2011 Skip the login if the user has been locked. // 04/16/2013 Throw an exception so that we can track lockout count failures in the error log. //if (SplendidInit.LoginFailures(Application, txtUSER_NAME.Text) >= Crm.Password.LoginLockoutCount(Application)) //{ // L10N L10n = new L10N("en-US"); // throw (new Exception(L10n.Term("Users.ERR_USER_LOCKED_OUT"))); //} // 04/16/2013 Allow system to be restricted by IP Address. if (SplendidInit.InvalidIPAddress(Application, Request.UserHostAddress)) { L10N L10n = new L10N("en-US"); throw (new Exception(L10n.Term("Users.ERR_INVALID_IP_ADDRESS"))); } bValidUser = SplendidInit.LoginUser(txtUSER_NAME.Text, txtPASSWORD.Text, String.Empty, String.Empty, String.Empty, false, false); } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); //trError.Visible = true; lblError.Text = ex.Message; return; } // 09/12/2006 Move redirect outside try/catch to avoid catching "Thread was being aborted" exception. if (bValidUser) { // 02/22/2011 The login redirect is also needed after the change password. LoginRedirect(); return; } else { //trError.Visible = true; lblError.Text = "提示:用户名或密码错误。"; } } } else if (e.CommandName == "ForgotPassword") { //trError.Visible = false; lblError.Text = String.Empty; pnlForgotPassword.Style.Remove("display"); try { txtFORGOT_USER_NAME.Text = txtFORGOT_USER_NAME.Text.Trim(); txtFORGOT_EMAIL.Text = txtFORGOT_EMAIL.Text.Trim(); if (!Security.IsWindowsAuthentication()) { DbProviderFactory dbf = DbProviderFactories.GetFactory(Application); using (IDbConnection con = dbf.CreateConnection()) { con.Open(); string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwUSERS " + ControlChars.CrLf + " where lower(USER_NAME) = @USER_NAME" + ControlChars.CrLf + " and lower(EMAIL1 ) = @EMAIL1 " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@USER_NAME", txtFORGOT_USER_NAME.Text.ToLower()); Sql.AddParameter(cmd, "@EMAIL1", txtFORGOT_EMAIL.Text.ToLower()); using (IDataReader rdr = cmd.ExecuteReader()) { //string sApplicationPath = Sql.ToString(Application["rootURL"]); Guid gUSER_LOGIN_ID = Guid.Empty; if (rdr.Read()) { MailMessage mail = new MailMessage(); string sFromName = Sql.ToString(Application["CONFIG.fromname"]); string sFromAddress = Sql.ToString(Application["CONFIG.fromaddress"]); if (!Sql.IsEmptyString(sFromAddress) && !Sql.IsEmptyString(sFromName)) mail.From = new MailAddress(sFromAddress, sFromName); else mail.From = new MailAddress(sFromAddress); mail.To.Add(new MailAddress(txtFORGOT_EMAIL.Text)); // 10/05/2008 If there are no recipients, then exit early. if (mail.To.Count == 0 && mail.CC.Count == 0 && mail.Bcc.Count == 0) return; Guid gPASSWORD_ID = Guid.Empty; SqlProcs.spUSERS_PASSWORD_LINK_InsertOnly(ref gPASSWORD_ID, txtFORGOT_USER_NAME.Text); string sSiteURL = Crm.Config.SiteURL(Application); string sResetURL = sSiteURL + "Users/ChangePassword.aspx?ID=" + gPASSWORD_ID.ToString(); string sSubject = L10n.Term("Users.LBL_RESET_PASSWORD_SUBJECT"); if (Sql.IsEmptyString(sSubject)) sSubject = "Reset your password"; string sBodyHtml = L10n.Term("Users.LBL_RESET_PASSWORD_BODY"); if (Sql.IsEmptyString(sBodyHtml)) { sBodyHtml += "<p>A password reset was requested.</p>\n"; sBodyHtml += "<p>Please click the following link to reset your password:</p>\n"; sBodyHtml += "<p><a href=\"{0}\">{0}</a></p>\n"; } if (sBodyHtml.IndexOf("{0}") < 0) { sBodyHtml += "<p><a href=\"{0}\">{0}</a></p>\n"; } sBodyHtml = String.Format(sBodyHtml, sResetURL); mail.Subject = sSubject; mail.Body = sBodyHtml; mail.IsBodyHtml = true; mail.BodyEncoding = System.Text.Encoding.UTF8; //SmtpClient client = EmailUtils.CreateSmtpClient(Application); //client.Send(mail); trForgotError.Visible = true; lblForgotError.Text = L10n.Term("Users.LBL_RESET_PASSWORD_STATUS"); } else { trForgotError.Visible = true; lblForgotError.Text = L10n.Term("Users.ERR_INVALID_FORGOT_PASSWORD"); } } } } } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); trForgotError.Visible = true; lblForgotError.Text = ex.Message; return; } } }
private void Page_Load(object sender, System.EventArgs e) { #if DEBUG bDebug = true; #endif if (Request.Cookies["showLeftCol"] != null) { bShowLeftCol = Sql.ToBoolean(Request.Cookies["showLeftCol"].Value); } else { HttpCookie cShowLeftCol = new HttpCookie("showLeftCol", bShowLeftCol ? "true" : "false"); cShowLeftCol.Expires = DateTime.Now.AddDays(30); cShowLeftCol.Path = "/"; Response.Cookies.Add(cShowLeftCol); } imgHideHandle.Style.Remove("display"); imgShowHandle.Style.Remove("display"); tdShortcuts.Style.Remove("display"); imgHideHandle.Style.Add("display", bShowLeftCol ? "inline" : "none"); imgShowHandle.Style.Add("display", !bShowLeftCol ? "inline" : "none"); tdShortcuts.Style.Add("display", bShowLeftCol ? "inline" : "none"); if (!IsPostBack) { // 06/09/2006 Paul. Remove data binding in the user controls. Binding is required, but only do so in the ASPX pages. //Page.DataBind(); // 04/28/2006 Paul. If the user has not authenticated, then this must be during login. Disable the search. // 11/17/2007 Paul. New function to determine if user is authenticated. if (!Security.IsAuthenticated()) { cntUnifiedSearch.Visible = false; } if (imgCompanyLogo != null) { // 04/16/2006 Paul. Company logo can be customized. if (!Sql.IsEmptyString(Application["CONFIG.header_logo_image"])) { imgCompanyLogo.ImageUrl = Sql.ToString(Application["imageURL"]) + Sql.ToString(Application["CONFIG.header_logo_image"]); if (Sql.ToInteger(Application["CONFIG.header_logo_width"]) > 0) { imgCompanyLogo.Width = Sql.ToInteger(Application["CONFIG.header_logo_width"]); } if (Sql.ToInteger(Application["CONFIG.header_logo_height"]) > 0) { imgCompanyLogo.Height = Sql.ToInteger(Application["CONFIG.header_logo_height"]); } if (!Sql.IsEmptyString(Application["CONFIG.header_logo_style"])) { imgCompanyLogo.Attributes.Add("style", Sql.ToString(Application["CONFIG.header_logo_style"])); } imgCompanyLogo.AlternateText = L10n.Term(".COMPANY_LOGO"); } else { imgCompanyLogo.ImageUrl = Sql.ToString(Application["imageURL"]) + "SplendidCRM_Logo.gif"; imgCompanyLogo.Width = 207; imgCompanyLogo.Height = 60; imgCompanyLogo.Attributes.Add("style", "margin-left: 10px"); imgCompanyLogo.AlternateText = L10n.Term(".COMPANY_LOGO"); } } } string sSeparator = " "; DataTable dt = SplendidCache.TabMenu(); // 04/28/2006 Paul. Hide the footer menu if there is no menu to display. if (dt.Rows.Count == 0) { trFooterMenu.Visible = false; tblTheme.Visible = false; } int nRow = 0; int nDisplayedTabs = 0; int nMaxTabs = Sql.ToInteger(Session["max_tabs"]); // 09/24/2007 Paul. Max tabs is a config variable and needs the CONFIG in front of the name. if (nMaxTabs == 0) { nMaxTabs = Sql.ToInteger(Application["CONFIG.default_max_tabs"]); } if (nMaxTabs == 0) { nMaxTabs = 12; } for ( ; nRow < dt.Rows.Count; nRow++) { DataRow row = dt.Rows[nRow]; Literal litSeparator = new Literal(); litSeparator.Text = sSeparator; phFooterMenu.Controls.Add(litSeparator); HyperLink lnk = new HyperLink(); // 05/31/2007 Paul. Don't specify an ID for the control. // A customer reported an error with a duplicate entry. //lnk.ID = "lnkFooter" + Sql.ToString(row["DISPLAY_NAME"]) ; lnk.NavigateUrl = Sql.ToString(row["RELATIVE_PATH"]); lnk.Text = L10n.Term(Sql.ToString(row["DISPLAY_NAME"])); lnk.CssClass = "footerLink"; phFooterMenu.Controls.Add(lnk); nDisplayedTabs++; if (nDisplayedTabs % nMaxTabs == 0) { sSeparator = "\r\n<br />\r\n"; } else { sSeparator = "\r\n| "; } } // 04/28/2006 Paul. No need to populate the lists if they are not going to be displayed. if (!IsPostBack && dt.Rows.Count > 0) { lstLANGUAGE.DataSource = SplendidCache.Languages(); lstLANGUAGE.DataBind(); try { lstTHEME.DataSource = SplendidCache.Themes(); lstTHEME.DataBind(); lstTHEME.SelectedValue = Sql.ToString(HttpContext.Current.Session["USER_SETTINGS/THEME"]); } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); } try { // http://www.i18nguy.com/temp/rtl.html if (htmlRoot != null) { if (L10n.IsLanguageRTL()) { htmlRoot.Attributes.Add("dir", "rtl"); } } } catch { } try { lstLANGUAGE.SelectedValue = L10n.NAME; } catch { } } }
private void UserLogin(string userName,string password) { bool bValidUser = false; try { // 02/20/2011 Skip the login if the user has been locked. // 04/16/2013 Throw an exception so that we can track lockout count failures in the error log. //if (SplendidInit.LoginFailures(Application, userName) >= Crm.Password.LoginLockoutCount(Application)) //{ // L10N L10n = new L10N("en-US"); // throw (new Exception(L10n.Term("Users.ERR_USER_LOCKED_OUT"))); //} // 04/16/2013 Allow system to be restricted by IP Address. if (SplendidInit.InvalidIPAddress(Application, Request.UserHostAddress)) { L10N L10n = new L10N("en-US"); throw (new Exception(L10n.Term("Users.ERR_INVALID_IP_ADDRESS"))); } bValidUser = SplendidInit.LoginUser(userName, password, String.Empty, String.Empty, String.Empty, false, false); } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); //trError.Visible = true; lblError.Text = ex.Message; return; } // 09/12/2006 Move redirect outside try/catch to avoid catching "Thread was being aborted" exception. if (bValidUser) { // 02/22/2011 The login redirect is also needed after the change password. LoginRedirect(); return; } else { //trError.Visible = true; lblError.Text = "提示:用户名或密码错误。"; } }