push update socket data dan token
This commit is contained in:
No files matched your search
@@ -4,22 +4,19 @@ export default defineEventHandler(async (event) => {
|
||||
const config = useRuntimeConfig();
|
||||
console.log('🚪 Logout handler called');
|
||||
|
||||
// Get the current session to retrieve tokens
|
||||
const sessionId = getCookie(event, 'user_session');
|
||||
// Get the current session to retrieve ID token for proper Keycloak logout
|
||||
const sessionCookie = getCookie(event, 'user_session');
|
||||
let idToken = null;
|
||||
|
||||
if (sessionId) {
|
||||
if (sessionCookie) {
|
||||
try {
|
||||
const { getSession, deleteSession } = await import('~/server/utils/sessionStore');
|
||||
const session = getSession(sessionId);
|
||||
if (session) {
|
||||
idToken = session.idToken;
|
||||
console.log('🔑 ID token found in session:', !!idToken);
|
||||
// Delete session from store
|
||||
deleteSession(sessionId);
|
||||
}
|
||||
// Decode JWT-based session from cookie
|
||||
const sessionJson = Buffer.from(sessionCookie, 'base64').toString('utf-8');
|
||||
const session = JSON.parse(sessionJson);
|
||||
idToken = session.idToken;
|
||||
console.log('🔑 ID token found in session:', !!idToken);
|
||||
} catch (error) {
|
||||
console.warn('⚠️ Could not retrieve session:', error);
|
||||
console.warn('⚠️ Could not parse session cookie:', error);
|
||||
}
|
||||
} else {
|
||||
console.warn('⚠️ No session cookie found');
|
||||
|
||||
Reference in New Issue
Block a user