protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack && Convert.ToInt32(Session["retryAuth"]) != Convert.ToInt32(ConfigurationManager.AppSettings["PersonifyRetryCount"]))
        {
            _wsSso = new service {
                Url = _personifySsoUrl
            };

            if (Request.QueryString["action"] == "logout")
            {
                string returnUrl;

                if (Request.QueryString["returnUrl"] != null && !string.IsNullOrEmpty(Request.QueryString["returnUrl"]))
                {
                    returnUrl = Request.QueryString["returnUrl"];
                }
                else
                {
                    returnUrl = Request.ServerVariables["PATH_INFO"];
                }

                if (_wsSso != null)
                {
                    _wsSso.Dispose();
                }


                if (returnUrl.ToLower().Trim().Contains("?logging_out") == false)
                {
                    returnUrl = returnUrl + "?logging_out=true";
                }

                Response.Redirect(returnUrl, true);
            }
            else
            {
                if (!(CMS.Membership.AuthenticationHelper.IsAuthenticated()))
                {
                    try
                    {
                        CheckSsoToken();
                    }
                    catch (Exception execp)
                    {
                        EventLogProvider.LogException(execp.Source, execp.StackTrace, execp);
                    }
                }
                else
                {
                    bool flagpersonifyMember = false;

                    if (CMS.Membership.AuthenticationHelper.IsAuthenticated())
                    {
                        UserInfo userdata =
                            CMS.Membership.UserInfoProvider.GetUserInfo(MembershipContext.AuthenticatedUser.UserName);

                        DataTable dt = UserInfoProvider.GetUserRoles(userdata);

                        if (dt.Rows.Count > 0 && dt != null)
                        {
                            foreach (DataRow dr in dt.Rows)
                            {
                                if (dr["RoleName"].ToString().ToLower().Contains("peronifyuser"))
                                {
                                    flagpersonifyMember = true;
                                }
                            }
                        }
                    }

                    if (Session[PersonifySessionKey] == null && flagpersonifyMember)
                    {
                        objKenticoService.Logout(MembershipContext.AuthenticatedUser.UserName);
                    }
                }
            }
        }
    }
예제 #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // LoginMember("*****@*****.**", "Password1", true);
        if (!Page.IsPostBack)
        {
            _wsSso = new service {
                Url = _personifySsoUrl
            };

            if (Request.QueryString["action"] == "logout")
            {
                //  var userApi = new UserAPI();
                //  Logout(userApi, Session[PersonifySessionKey] != null ? Session[PersonifySessionKey].ToString() : null);
                //  objKenticoService.Logout("");
                string returnUrl;

                if (Request.QueryString["returnUrl"] != null && !string.IsNullOrEmpty(Request.QueryString["returnUrl"]))
                {
                    returnUrl = Request.QueryString["returnUrl"];
                }
                else
                {
                    returnUrl = Request.ServerVariables["PATH_INFO"];
                }

                if (_wsSso != null)
                {
                    _wsSso.Dispose();
                }


                if (returnUrl.ToLower().Trim().Contains("?logging_out") == false)
                {
                    returnUrl = returnUrl + "?logging_out=true";
                }

                Response.Redirect(returnUrl, true);
            }
            else
            {
                if (!(CMS.Membership.AuthenticationHelper.IsAuthenticated()))
                {
                    CheckSsoToken();
                }
                else
                {
                    bool flagpersonifyMember = false;

                    if (CMS.Membership.AuthenticationHelper.IsAuthenticated())
                    {
                        UserInfo userdata =
                            CMS.Membership.UserInfoProvider.GetUserInfo(MembershipContext.AuthenticatedUser.UserName);

                        DataTable dt = UserInfoProvider.GetUserRoles(userdata);

                        if (dt.Rows.Count > 0 && dt != null)
                        {
                            foreach (DataRow dr in dt.Rows)
                            {
                                if (dr["RoleName"].ToString().ToLower().Contains("peronifyuser"))
                                {
                                    flagpersonifyMember = true;
                                }
                            }
                        }
                    }

                    if (Session[PersonifySessionKey] == null && flagpersonifyMember)
                    {
                        objKenticoService.Logout(MembershipContext.AuthenticatedUser.UserName);
                    }
                }
            }
        }
    }