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)); }
/// <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); } } } } }
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 }); }
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 }); }
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); } }