/// <summary> /// Terminates a user session. /// </summary> /// <param name="sessionToken">The token of the user session.</param> public virtual void Logout(string sessionToken) { string userName = sessionCache.RetrieveFromCache(sessionToken); if (!string.IsNullOrEmpty(userName)) { sessionCache.RemoveFromCache(sessionToken); Log.Debug(string.Format(System.Globalization.CultureInfo.CurrentCulture, "{0} has logged out", userName)); LogEvent(null, userName, SecurityEvent.Logout, SecurityRight.Allow, null); } else { LogEvent(null, null, SecurityEvent.Logout, SecurityRight.Deny, "Session has already been logged out"); } }
public void LogoutRemovesSessionFromCache() { Expect.Call(sessionMock.RetrieveFromCache(testSessionToken)).Return(testSessionToken); Expect.Call(delegate { sessionMock.RemoveFromCache(testSessionToken); }); mocks.ReplayAll(); manager.Initialise(); manager.Logout(testSessionToken); }