コード例 #1
0
        public ActionResult Logout(string back)
        {
            var info = new CancellableLoginInfo {
                UserName = SNCR.User.Current.Username
            };

            LoginExtender.OnLoggingOut(info);

            FormsAuthentication.SignOut();

            if (!info.Cancel)
            {
                Logger.WriteAudit(AuditEvent.Logout, new Dictionary <string, object> {
                    { "UserName", SNCR.User.Current.Username }, { "ClientAddress", Request.ServerVariables["REMOTE_ADDR"] }
                });
                LoginExtender.OnLoggedOut(new LoginInfo {
                    UserName = SNCR.User.Current.Username
                });
            }

            Session.Clear();

            back = string.IsNullOrEmpty(back) ? "/" : HttpUtility.UrlDecode(back);

            return(this.Redirect(back));
        }
コード例 #2
0
        /// <summary>
        /// Logs out the current user.
        /// </summary>
        /// <param name="ultimateLogout">Whether this should be an ultimate logout. If set to True, the user will be logged out from all clients.</param>
        public static void Logout(bool ultimateLogout = false)
        {
            var user = User.Current;
            var info = new CancellableLoginInfo {
                UserName = user.Username
            };

            LoginExtender.OnLoggingOut(info);

            if (info.Cancel)
            {
                return;
            }

            FormsAuthentication.SignOut();

            AccessTokenVault.DeleteTokensByUser(user.Id);

            SnLog.WriteAudit(AuditEvent.Logout,
                             new Dictionary <string, object>
            {
                { "UserName", user.Username },
                { "ClientAddress", RepositoryTools.GetClientIpAddress() }
            });

            LoginExtender.OnLoggedOut(new LoginInfo {
                UserName = user.Username
            });

            if (HttpContext.Current != null)
            {
                if (HttpContext.Current.Session != null)
                {
                    HttpContext.Current.Session.Abandon();
                }

                // remove session cookie
                var sessionCookie = new HttpCookie(GetSessionIdCookieName(), string.Empty)
                {
                    Expires = DateTime.UtcNow.AddDays(-1)
                };

                HttpContext.Current.Response.Cookies.Add(sessionCookie);

                // in case of ultimate logout saves the time on user
                if (ultimateLogout || Configuration.Security.DefaultUltimateLogout)
                {
                    using (new SystemAccount())
                    {
                        if (user is User userNode)
                        {
                            userNode.LastLoggedOut = DateTime.UtcNow;
                            userNode.Save(SavingMode.KeepVersion);
                        }
                    }
                }
            }
        }
コード例 #3
0
ファイル: LoginView.cs プロジェクト: vlslavik/SenseNet
 protected void LoginStatus_LoggedOut(object sender, EventArgs e)
 {
     Logger.WriteAudit(AuditEvent.Logout, new Dictionary <string, object> {
         { "UserName", User.Current.Username }, { "ClientAddress", Request.ServerVariables["REMOTE_ADDR"] }
     });
     if (OnUserLoggedOut != null)
     {
         OnUserLoggedOut(sender, e);
     }
     LoginExtender.OnLoggedOut(new LoginInfo {
         UserName = User.Current.Username
     });
 }
コード例 #4
0
 protected void LoginStatus_LoggedOut(object sender, EventArgs e)
 {
     SnLog.WriteAudit(AuditEvent.Logout,
                      new Dictionary <string, object>
     {
         { "UserName", User.Current.Username },
         { "ClientAddress", RepositoryTools.GetClientIpAddress() }
     });
     if (OnUserLoggedOut != null)
     {
         OnUserLoggedOut(sender, e);
     }
     LoginExtender.OnLoggedOut(new LoginInfo {
         UserName = User.Current.Username
     });
 }
コード例 #5
0
        public static void Logout()
        {
            var info = new CancellableLoginInfo {
                UserName = User.Current.Username
            };

            LoginExtender.OnLoggingOut(info);

            if (info.Cancel)
            {
                return;
            }

            FormsAuthentication.SignOut();

            SnLog.WriteAudit(AuditEvent.Logout,
                             new Dictionary <string, object>
            {
                { "UserName", User.Current.Username },
                { "ClientAddress", RepositoryTools.GetClientIpAddress() }
            });

            LoginExtender.OnLoggedOut(new LoginInfo {
                UserName = User.Current.Username
            });

            if (HttpContext.Current != null)
            {
                if (HttpContext.Current.Session != null)
                {
                    HttpContext.Current.Session.Abandon();
                }

                // remove session cookie
                var sessionCookie = new HttpCookie(GetSessionIdCookieName(), string.Empty)
                {
                    Expires = DateTime.UtcNow.AddDays(-1)
                };

                HttpContext.Current.Response.Cookies.Add(sessionCookie);
            }
        }