update hak akses dan perbaikan api pembuatan tiket

This commit is contained in:
Fanrouver
2026-04-20 09:42:03 +07:00
parent 94ff9f55d9
commit 2bf00eff3c
38 changed files with 2054 additions and 2552 deletions

No files matched your search

+16
View File
@@ -65,6 +65,22 @@ export function deleteSession(sessionId: string): void {
console.log(`🗑️ Session deleted: ${sessionId.substring(0, 8)}... (Remaining: ${sessions.size})`);
}
export function updateSession(sessionId: string, updates: Partial<SessionData>): boolean {
const session = sessions.get(sessionId);
if (!session) {
return false;
}
// Update the session with new data
const updatedSession = {
...session,
...updates,
};
sessions.set(sessionId, updatedSession);
return true;
}
// Helper function to get session from cookie (for API handlers)
export async function getSessionFromCookie(event: any): Promise<SessionData | null> {
const { getCookie } = await import('h3');
+13 -1
View File
@@ -97,6 +97,18 @@ const decodeTokenPayload = (token: string | undefined): any | null => {
}
};
// Helper to convert string to slug
export const slugify = (text: string): string => {
if (!text) return '';
return text
.toString()
.toLowerCase()
.trim()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w-]+/g, '') // Remove all non-word chars
.replace(/--+/g, '-'); // Replace multiple - with single -
};
/**
* Sync user data from JWT tokens to database
* @param idToken - The ID token from Keycloak
@@ -178,7 +190,7 @@ export const syncUserFromTokens = (
if (typeof lastGroup === 'string') {
const parts = lastGroup.split('/').filter(Boolean);
if (parts.length > 0) {
tipeUser = parts[parts.length - 1]; // Get last part of path
tipeUser = slugify(parts[parts.length - 1]); // Get last part of path and slugify it
}
}
}