protected void btnLogin_Click(object sender, EventArgs e) { try { string loginText = txtUser.Text; if (loginText != null && loginText.Contains(":")) { this.Master.Message = PXMessages.LocalizeNoPrefix(PX.AscxControlsMessages.LoginScreen.IncorrectLoginSymbols); return; } if (String.IsNullOrEmpty(loginText)) { this.Master.Message = PXMessages.LocalizeNoPrefix(PX.AscxControlsMessages.LoginScreen.InvalidLogin); return; } if (String.IsNullOrEmpty(txtNewPassword.Text) && String.IsNullOrEmpty(txtConfirmPassword.Text)) { string[] companies = null; if (PXDatabase.SecureCompanyID && (Membership.Provider is PXBaseMembershipProvider) && String.IsNullOrEmpty(txtVeryDummyPass.Value) && (companies = PXAccess.GetCompanies(loginText, txtPass.Text)).Length > 1) { SecureLogin(companies); } else { NormalLogin(companies); } } else //if user should change it password than we will login different way { ChangingPassword(); } } catch (PXException ex) { this.Master.Message = ex.MessageNoPrefix; } catch (System.Reflection.TargetInvocationException ex) { this.Master.Message = PXException.ExtractInner(ex).Message; } catch (Exception ex) { this.Master.Message = ex.Message; } }
/// <summary> /// /// </summary> protected void Page_Load(object sender, EventArgs e) { if (cmbLang.SelectedValue != null) { System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(cmbLang.SelectedValue); btnLogin.Text = PXMessages.LocalizeNoPrefix(PX.AscxControlsMessages.LoginScreen.SignIn); txtUser.Attributes["placeholder"] = PXMessages.LocalizeNoPrefix(Msg.LoginPageUserName); txtPass.Attributes["placeholder"] = PXMessages.LocalizeNoPrefix(Msg.LoginPagePassword); txtNewPassword.Attributes["placeholder"] = PXMessages.LocalizeNoPrefix(Msg.LoginPageNewPassword); txtConfirmPassword.Attributes["placeholder"] = PXMessages.LocalizeNoPrefix(Msg.LoginPageConfirmPassword); lnkForgotPswd.Text = PXMessages.LocalizeNoPrefix(Msg.LoginPageForgotCredentials); } lbl2FactorCap.Text = PXMessages.LocalizeNoPrefix(PX.AscxControlsMessages.LoginScreen.TwoFactorAuth); lbl2FactorMethod.Text = PXMessages.LocalizeNoPrefix(PX.AscxControlsMessages.LoginScreen.TwoFactorSelectMethod); rememberDevice.Text = PXMessages.LocalizeNoPrefix(PX.AscxControlsMessages.LoginScreen.RememberDevice); if (PX.Data.Update.PXUpdateHelper.CheckUpdateLock()) { throw new PXUnderMaintenanceException(); } var lockoutStatus = PXSiteLockout.GetStatus(true); if (lockoutStatus == PXSiteLockout.Status.Locked) { lblUnderMaintenance.Text = PXMessages.Localize(PX.Data.Update.Messages.SiteUnderMaintenance); lblUnderMaintenance.Visible = true; if (!string.IsNullOrWhiteSpace(PXSiteLockout.Message)) { lblUnderMaintenanceReason.Text = string.Format( PXMessages.Localize(PX.Data.Update.Messages.LockoutReason), PXSiteLockout.Message); lblUnderMaintenanceReason.Visible = true; } } if (lockoutStatus == PXSiteLockout.Status.Pending) { string datetime = string.Format("{0} ({1} UTC)", PXSiteLockout.DateTime, PXSiteLockout.DateTimeUtc); lblUnderMaintenance.Text = string.Format( PXMessages.Localize(PX.Data.Update.Messages.PendingLockout), datetime, PXSiteLockout.Message); lblUnderMaintenance.Visible = true; } if (GetPostBackControl(this.Page) == cmbCompany || GetPostBackControl(this.Page) == cmbLang) { txtPass.Attributes.Add("value", txtPass.Text); } if (GetPostBackControl(this.Page) == btnLogin && !String.IsNullOrEmpty(txtDummyCpny.Value)) { cmbCompany.SelectedValue = txtDummyCpny.Value; } if (string.IsNullOrWhiteSpace(MultiFactorPipelineNotStarted.Value)) { MultiFactorPipelineNotStarted.Value = "true"; } // if user already set password then we should disabling login and password if (!String.IsNullOrEmpty(txtVeryDummyPass.Value)) { txtPass.Text = txtVeryDummyPass.Value; DisablingUserPassword(); if (!MultiCompaniesSecure) { EnablingChangingPassword(); } } // if (SecureCompanyID) then we should hide combobox before first login. // and also we should shrink companies list if (PXDatabase.SecureCompanyID && (Membership.Provider is PXBaseMembershipProvider)) { this.cmbCompany.Visible = !String.IsNullOrEmpty(txtVeryDummyPass.Value); if (!String.IsNullOrEmpty(txtVeryDummyPass.Value)) { List <String> companyFilter = new List <String>(PXAccess.GetCompanies(txtUser.Text, txtVeryDummyPass.Value)); for (int i = cmbCompany.Items.Count - 1; i >= 0; i--) { ListItem item = cmbCompany.Items[i]; if (!companyFilter.Contains(item.Value)) { cmbCompany.Items.RemoveAt(i); } } } } // Is user trying to recover his password using link from Email? if (Request.QueryString.AllKeys.Length > 0 && Request.QueryString.GetValues("gk") != null) { RemindUserPassword(); } try { this.SetInfoText(); } catch { /*SKIP ERROS*/ } this.idStorage.Value = seed; //try silent login btnLoginSilent_Click(sender, e); }
/// <summary> /// /// </summary> protected void Page_Load(object sender, EventArgs e) { if (PX.Data.Update.PXUpdateHelper.CheckUpdateLock()) { throw new PXUnderMaintenanceException(); } var lockoutStatus = PXSiteLockout.GetStatus(true); if (lockoutStatus == PXSiteLockout.Status.Locked) { lblUnderMaintenance.Text = PXMessages.Localize(PX.Data.Update.Messages.SiteUnderMaintenance); lblUnderMaintenance.Visible = true; if (!string.IsNullOrWhiteSpace(PXSiteLockout.Message)) { lblUnderMaintenanceReason.Text = string.Format( PXMessages.Localize(PX.Data.Update.Messages.LockoutReason), PXSiteLockout.Message); lblUnderMaintenanceReason.Visible = true; } } if (lockoutStatus == PXSiteLockout.Status.Pending) { string datetime = string.Format("{0} ({1} UTC)", PXSiteLockout.DateTime, PXSiteLockout.DateTimeUtc); lblUnderMaintenance.Text = string.Format( PXMessages.Localize(PX.Data.Update.Messages.PendingLockout), datetime, PXSiteLockout.Message); lblUnderMaintenance.Visible = true; } if (GetPostBackControl(this.Page) == cmbCompany) { txtPass.Attributes.Add("value", txtPass.Text); } if (GetPostBackControl(this.Page) == btnLogin && !String.IsNullOrEmpty(txtDummyCpny.Value)) { cmbCompany.SelectedValue = txtDummyCpny.Value; } // if user already set password then we should disabling login and password if (!String.IsNullOrEmpty(txtVeryDummyPass.Value)) { txtPass.Text = txtVeryDummyPass.Value; DisablingUserPassword(); if (!MultiCompaniesSecure) { EnablingChangingPassword(); } } // if (SecureCompanyID) then we should hide combobox before first login. // and also we should shrink companies list if (PXDatabase.SecureCompanyID && (Membership.Provider is PXBaseMembershipProvider)) { this.cmbCompany.Visible = !String.IsNullOrEmpty(txtVeryDummyPass.Value); if (!String.IsNullOrEmpty(txtVeryDummyPass.Value)) { List <String> companyFilter = new List <String>(PXAccess.GetCompanies(txtUser.Text, txtVeryDummyPass.Value)); for (int i = cmbCompany.Items.Count - 1; i >= 0; i--) { ListItem item = cmbCompany.Items[i]; if (!companyFilter.Contains(item.Value)) { cmbCompany.Items.RemoveAt(i); } } } } // Is user trying to recover his password using link from Email? if (Request.QueryString.AllKeys.Length > 0 && Request.QueryString.GetValues("gk") != null) { RemindUserPassword(); } try { this.SetInfoText(); } catch { /*SKIP ERROS*/ } this.idStorage.Value = seed; //try silent login btnLoginSilent_Click(sender, e); }