FIX: Replace useOidcAuth with useCustomAuth in useUnifiedAuth
## **Critical Fix for 500 Error:** ### **Issue:** - useUnifiedAuth.ts was still calling useOidcAuth() which no longer exists - This was causing the 500 error when dashboard tried to load - Error: 'useOidcAuth is not defined' ### **Solution:** - Replaced useOidcAuth() with useCustomAuth() in unified auth - Updated logout logic to use custom Keycloak auth - Maintained dual auth support (Directus + Keycloak) ### **Files Changed:** - composables/useUnifiedAuth.ts - Updated to use custom auth system ## **Next Step:** Need to resolve TypeScript import issue for useCustomAuth composable
This commit is contained in:
parent
bff185e4ac
commit
81316a4294
|
|
@ -11,27 +11,24 @@ export const useUnifiedAuth = () => {
|
|||
// Get both auth systems
|
||||
const directusAuth = useDirectusAuth();
|
||||
const directusUser = useDirectusUser();
|
||||
const oidc = useOidcAuth();
|
||||
const customAuth = useCustomAuth();
|
||||
|
||||
// Create unified user object
|
||||
const user = computed<UnifiedUser | null>(() => {
|
||||
// Check OIDC (Keycloak) user first
|
||||
if (oidc.loggedIn?.value && oidc.user?.value) {
|
||||
const oidcUser = oidc.user.value as any; // Type cast for flexibility
|
||||
// Check custom Keycloak auth first
|
||||
if (customAuth.authenticated?.value && customAuth.user?.value) {
|
||||
const keycloakUser = customAuth.user.value as any; // Type cast for flexibility
|
||||
|
||||
// Construct name from available fields
|
||||
let name = oidcUser.name || oidcUser.preferred_username || oidcUser.email || 'User';
|
||||
if (!name && (oidcUser.given_name || oidcUser.family_name)) {
|
||||
name = `${oidcUser.given_name || ''} ${oidcUser.family_name || ''}`.trim();
|
||||
}
|
||||
let name = keycloakUser.name || keycloakUser.username || keycloakUser.email || 'User';
|
||||
|
||||
return {
|
||||
id: oidcUser.sub || oidcUser.id || 'unknown',
|
||||
email: oidcUser.email || '',
|
||||
id: keycloakUser.id || 'unknown',
|
||||
email: keycloakUser.email || '',
|
||||
name: name,
|
||||
tier: 'basic', // Could be enhanced with Keycloak attributes
|
||||
authSource: 'keycloak',
|
||||
raw: oidcUser
|
||||
raw: keycloakUser
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -53,8 +50,8 @@ export const useUnifiedAuth = () => {
|
|||
// Unified logout function
|
||||
const logout = async () => {
|
||||
if (user.value?.authSource === 'keycloak') {
|
||||
// OIDC logout
|
||||
await oidc.logout();
|
||||
// Custom Keycloak logout
|
||||
await customAuth.logout();
|
||||
} else if (user.value?.authSource === 'directus') {
|
||||
// Directus logout
|
||||
await directusAuth.logout();
|
||||
|
|
|
|||
Loading…
Reference in New Issue