public async Task <IHttpActionResult> Logout(string id = null) { var user = (ClaimsPrincipal)User; if (user != null && user.Identity.IsAuthenticated) { var sub = user.GetSubjectId(); Logger.InfoFormat("Logout requested for subject: {0}", sub); } sessionCookie.ClearSessionId(); signOutMessageCookie.Clear(id); ClearAuthenticationCookies(); SignOutOfExternalIdP(); if (user != null && user.Identity.IsAuthenticated) { await this.userService.SignOutAsync(user); var message = signOutMessageCookie.Read(id); eventService.RaiseLogoutEvent(user, id, message); } return(await RenderLoggedOutPage(id)); }
private void ClearCookies() { // session id cookie _sessionCookie.ClearSessionId(); // client list cookie _clientListCookie.Clear(); }
public async Task <IHttpActionResult> Logout(string id = null) { Logger.Info("Logout endpoint submitted"); if (id != null && id.Length > MaxSignInMessageLength) { Logger.Error("id param is longer than allowed length"); return(RenderErrorPage()); } var user = (ClaimsPrincipal)User; if (user != null && user.Identity.IsAuthenticated) { var sub = user.GetSubjectId(); Logger.InfoFormat("Logout requested for subject: {0}", sub); } Logger.Info("Clearing cookies"); sessionCookie.ClearSessionId(); signOutMessageCookie.Clear(id); ClearAuthenticationCookies(); SignOutOfExternalIdP(); if (user != null && user.Identity.IsAuthenticated) { var message = signOutMessageCookie.Read(id); var signOutContext = new SignOutContext { Subject = user }; if (message != null) { signOutContext.ClientId = message.ClientId; } await this.userService.SignOutAsync(signOutContext); await eventService.RaiseLogoutEventAsync(user, id, message); } return(await RenderLoggedOutPage(id)); }