示例#1
0
 protected override void Dispose(bool disposing)
 {
     if (HttpContext.Current != null && HttpContext.Current.Session != null)
     {
         PXLogin.LogoutUser(PXAccess.GetUserName(), HttpContext.Current.Session.SessionID);
     }
     FormsAuthenticationModule.SignOut();
     base.Dispose(disposing);
 }
示例#2
0
 protected void Logout(object sender, EventArgs e)
 {
     try
     {
         PXLogin.LogoutUser(PXAccess.GetUserName(), Session.SessionID);
         PXContext.Session.SetString("UserLogin", string.Empty);
         Session.Abandon();
         PX.Data.Auth.ExternalAuthHelper.SignOut(Context, "~/Frames/Outlook/FirstRun.html");
         PXDatabase.Delete <PX.SM.UserIdentity>(
             new PXDataFieldRestrict <PX.SM.UserIdentity.providerName>(PXDbType.VarChar, "ExchangeIdentityToken"),
             new PXDataFieldRestrict <PX.SM.UserIdentity.userID>(PXDbType.UniqueIdentifier, PXAccess.GetUserID())
             );
     }
     finally
     {
         PX.Data.Redirector.Redirect(System.Web.HttpContext.Current, "~/Frames/Outlook/FirstRun.html");
     }
 }
示例#3
0
    //-----------------------------------------------------------------------------
    /// <summary>
    /// Perform the user password changing.
    /// </summary>
    protected void ChangingPassword()
    {
        string loginText = txtUser.Text;

        if (txtRecoveryAnswer.Visible && !PXLogin.ValidateAnswer(PXDatabase.Companies.Length > 0 ?
                                                                 loginText + "@" + cmbCompany.SelectedItem.Value : loginText, txtRecoveryAnswer.Text))
        {
            this.Master.Message = PX.Data.PXMessages.LocalizeNoPrefix(PX.AscxControlsMessages.LoginScreen.InvalidRecoveryAnswer);
        }
        if (txtNewPassword.Text != txtConfirmPassword.Text)
        {
            this.Master.Message = PX.Data.PXMessages.LocalizeNoPrefix(PX.AscxControlsMessages.LoginScreen.PasswordNotConfirmed);
        }
        if ((string)PXContext.Session["ChangingPassword"] == txtNewPassword.Text)
        {
            this.Master.Message = PX.Data.PXMessages.LocalizeNoPrefix(PX.AscxControlsMessages.LoginScreen.NewPasswordMustDiffer);
        }
        if (string.IsNullOrEmpty(txtNewPassword.Text))
        {
            this.Master.Message = PX.Data.PXMessages.LocalizeNoPrefix(PX.AscxControlsMessages.LoginScreen.PasswordBlank);
        }

        string changingPass = (string)PXContext.Session["ChangingPassword"];

        if (!String.IsNullOrEmpty(this.Master.Message))
        {
            txtVeryDummyPass.Value = changingPass;
            DisablingUserPassword();
            EnablingChangingPassword();
            return;
        }

        string gk = Request.QueryString.Get("gk");

        if (gk == null && changingPass == null)
        {
            return;
        }

        string userName = PXDatabase.Companies.Length > 0
                        ? loginText + "@" + (cmbCompany.SelectedIndex != -1 ? cmbCompany.SelectedItem.Value : PXDatabase.Companies[0])
                        : loginText;

        try
        {
            PXLogin.LoginUser(
                ref userName,
                gk ?? changingPass,
                txtNewPassword.Text);
        }
        catch
        {
            txtVeryDummyPass.Value = changingPass;
            DisablingUserPassword();
            EnablingChangingPassword();

            throw;
        }

        bool isMultiFactorEnabled;

        string[] multifactorProviders;
        bool     isPasswordChanging;
        var      users = _multifactorService.GetUserIdsWithTwoFactorType(userName, txtNewPassword.Text, out isMultiFactorEnabled, out multifactorProviders, out isPasswordChanging);

        if (isMultiFactorEnabled)
        {
            PXLogin.LogoutUser(loginText, Session.SessionID);
            PXSessionContextFactory.Abandon();
            if (Request.QueryString["gk"] != null)
            {
                Page.Response.Redirect("~");
            }
            else
            {
                Page.Response.Redirect("~", true);
            }
            return;
        }

        PXLogin.InitUserEnvironment(userName, cmbLang.SelectedValue);
        AgreeToEula(loginText);
    }