public DeleteSession ( string sessionId ) : bool | ||
sessionId | string | |
Résultat | bool |
public bool DeleteSession(string sessionId)
{
// Delete user's session based on its session ID
Session s = Injection.Kernel.Get<ISessionRepository>().SessionForSessionId(sessionId);
// Ensure session actually belongs to this user
if (s != null && s.UserId == this.UserId)
{
return s.Delete();
}
return false;
}
/// <summary> /// Process logs this user out and destroys their current session /// <summary> public void Process(UriWrapper uri, IHttpProcessor processor, User user) { // Destroy session if (user.DeleteSession(user.SessionId)) { logger.IfInfo(String.Format("Logged out user, destroyed session: [user: {0}, key: {1}]", user.UserName, user.SessionId)); processor.WriteJson(new LogoutResponse(null, user.SessionId)); return; } processor.WriteJson(new LogoutResponse("Failed to destroy user session", user.SessionId)); return; }