Beispiel #1
0
        protected override void OnLoad(EventArgs e)
        {
            NameValueCollection logoutQS = new NameValueCollection {
            };

            if (User.Identity.IsAuthenticated)
            {
                logoutQS = QueryStringManager.MakeQueryString(loggedOut: true);
                Session.Clear();
                Session.Abandon();
                FormsAuthentication.SignOut();
            }

            // check for preferred redirection URL
            string target = Request.GetReturnUrl();

            if (!string.IsNullOrWhiteSpace(target))
            {
                Response.Redirect(target);
            }

            // check SSO application properties
            byte?       appID = Request.GetSsoAppID();
            Application app   = null;

            if (appID.HasValue)
            {
                app = CPSecurity.Provider.GetApplication(appID.Value);
            }
            if (app != null)
            {
                if (!string.IsNullOrWhiteSpace(app.Url))
                {
                    Response.Redirect(app.Url);
                }
                else
                {
                    Response.Redirect(FormsAuthentication.LoginUrl, new NameValueCollection {
                        { CPSecurity.QueryStringSsoAppIDParameter, app.ID.ToString() }, logoutQS
                    });
                }
            }

            // default redirection
            Response.Redirect(FormsAuthentication.LoginUrl, logoutQS);
        }
Beispiel #2
0
        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            byte?appID = Request.GetSsoAppID();

            if (appID.HasValue)
            {
                Cfb.CandidatePortal.Security.Sso.Application app = CPSecurity.Provider.GetApplication(appID.Value);
                if (app != null)
                {
                    _appNameLabel.Text = app.Name;
                    _signoutLink.HRef  = string.Format("{0}?{1}", _signoutLink.HRef, QueryStringManager.MakeQueryString(returnUrl: CPSecurity.GetSsoLoginUrl(appID.Value)).ToQueryString());
                }
            }
            else
            {
                _appNameLabel.Text = CPProviders.SettingsProvider.ApplicationName;
            }
        }