Пример #1
0
        public bool LogOutActiveConnection(int loginEventId)
        {
            try
            {
                var user     = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID);
                var userName = user.DisplayUserName(false);

                DbLoginEventsManager.LogOutEvent(loginEventId);

                MessageService.Send(Request, MessageAction.UserLogoutActiveConnection, userName);
                return(true);
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                return(false);
            }
        }
Пример #2
0
        protected override void OnPreInit(EventArgs e)
        {
            base.OnPreInit(e);

            if (!SecurityContext.IsAuthenticated)
            {
                if (CoreContext.Configuration.Personal)
                {
                    CheckSocialMedia();

                    SetLanguage();
                }

                var token = Request["asc_auth_key"];
                if (SecurityContext.AuthenticateMe(token))
                {
                    CookiesManager.SetCookies(CookiesType.AuthKey, token);

                    var refererURL = Request["refererURL"];
                    if (string.IsNullOrEmpty(refererURL))
                    {
                        refererURL = "~/Auth.aspx";
                    }

                    Response.Redirect(refererURL, true);
                }

                return;
            }

            if (IsLogout)
            {
                var cookie       = CookiesManager.GetCookies(CookiesType.AuthKey);
                int loginEventId = CookieStorage.GetLoginEventIdFromCookie(cookie);
                DbLoginEventsManager.LogOutEvent(loginEventId);

                var user      = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID);
                var loginName = user.DisplayUserName(false);
                MessageService.Send(HttpContext.Current.Request, loginName, MessageAction.Logout);

                ProcessLogout();

                if (!string.IsNullOrEmpty(user.SsoNameId))
                {
                    var settings = SsoSettingsV2.Load();

                    if (settings.EnableSso && !string.IsNullOrEmpty(settings.IdpSettings.SloUrl))
                    {
                        var logoutSsoUserData = Signature.Create(new LogoutSsoUserData
                        {
                            NameId    = user.SsoNameId,
                            SessionId = user.SsoSessionId
                        });

                        HttpContext.Current.Response.Redirect(SetupInfo.SsoSamlLogoutUrl + "?data=" + HttpUtility.UrlEncode(logoutSsoUserData), true);
                    }
                }

                Response.Redirect("~/Auth.aspx", true);
            }
            else
            {
                Response.Redirect(CommonLinkUtility.GetDefault(), true);
            }
        }