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
|
// Get both auth systems
|
||||||
const directusAuth = useDirectusAuth();
|
const directusAuth = useDirectusAuth();
|
||||||
const directusUser = useDirectusUser();
|
const directusUser = useDirectusUser();
|
||||||
const oidc = useOidcAuth();
|
const customAuth = useCustomAuth();
|
||||||
|
|
||||||
// Create unified user object
|
// Create unified user object
|
||||||
const user = computed<UnifiedUser | null>(() => {
|
const user = computed<UnifiedUser | null>(() => {
|
||||||
// Check OIDC (Keycloak) user first
|
// Check custom Keycloak auth first
|
||||||
if (oidc.loggedIn?.value && oidc.user?.value) {
|
if (customAuth.authenticated?.value && customAuth.user?.value) {
|
||||||
const oidcUser = oidc.user.value as any; // Type cast for flexibility
|
const keycloakUser = customAuth.user.value as any; // Type cast for flexibility
|
||||||
|
|
||||||
// Construct name from available fields
|
// Construct name from available fields
|
||||||
let name = oidcUser.name || oidcUser.preferred_username || oidcUser.email || 'User';
|
let name = keycloakUser.name || keycloakUser.username || keycloakUser.email || 'User';
|
||||||
if (!name && (oidcUser.given_name || oidcUser.family_name)) {
|
|
||||||
name = `${oidcUser.given_name || ''} ${oidcUser.family_name || ''}`.trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: oidcUser.sub || oidcUser.id || 'unknown',
|
id: keycloakUser.id || 'unknown',
|
||||||
email: oidcUser.email || '',
|
email: keycloakUser.email || '',
|
||||||
name: name,
|
name: name,
|
||||||
tier: 'basic', // Could be enhanced with Keycloak attributes
|
tier: 'basic', // Could be enhanced with Keycloak attributes
|
||||||
authSource: 'keycloak',
|
authSource: 'keycloak',
|
||||||
raw: oidcUser
|
raw: keycloakUser
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -53,8 +50,8 @@ export const useUnifiedAuth = () => {
|
||||||
// Unified logout function
|
// Unified logout function
|
||||||
const logout = async () => {
|
const logout = async () => {
|
||||||
if (user.value?.authSource === 'keycloak') {
|
if (user.value?.authSource === 'keycloak') {
|
||||||
// OIDC logout
|
// Custom Keycloak logout
|
||||||
await oidc.logout();
|
await customAuth.logout();
|
||||||
} else if (user.value?.authSource === 'directus') {
|
} else if (user.value?.authSource === 'directus') {
|
||||||
// Directus logout
|
// Directus logout
|
||||||
await directusAuth.logout();
|
await directusAuth.logout();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue