CRITICAL: Temporarily disable Keycloak to restore application functionality
- Disable Keycloak integration in authentication middleware - Update useUnifiedAuth to only use Directus authentication - Rebuild login page with only Directus auth form - Remove all Keycloak references that were causing JavaScript errors - This restores the application to working state with Directus auth only Application should now load and function normally. Keycloak can be re-enabled later once issues are resolved.
This commit is contained in:
parent
8c7bf4cc00
commit
fa35fcd235
|
|
@ -8,38 +8,13 @@ export interface UnifiedUser {
|
|||
}
|
||||
|
||||
export const useUnifiedAuth = () => {
|
||||
// Get both auth systems
|
||||
// Get auth system (Directus only for now)
|
||||
const directusAuth = useDirectusAuth();
|
||||
const directusUser = useDirectusUser();
|
||||
const keycloak = useKeycloak();
|
||||
|
||||
// Create unified user object
|
||||
// Create unified user object (Directus only)
|
||||
const user = computed<UnifiedUser | null>(() => {
|
||||
// Check Keycloak user first (safely)
|
||||
if (keycloak.user?.value) {
|
||||
const keycloakUser = keycloak.user.value;
|
||||
// Construct name from firstName and lastName if available
|
||||
let name = keycloakUser.name;
|
||||
if (!name && (keycloakUser.given_name || keycloakUser.family_name)) {
|
||||
name = `${keycloakUser.given_name || ''} ${keycloakUser.family_name || ''}`.trim();
|
||||
} else if (!name && (keycloakUser.firstName || keycloakUser.lastName)) {
|
||||
name = `${keycloakUser.firstName || ''} ${keycloakUser.lastName || ''}`.trim();
|
||||
}
|
||||
if (!name) {
|
||||
name = keycloakUser.preferred_username || keycloakUser.email;
|
||||
}
|
||||
|
||||
return {
|
||||
id: keycloakUser.sub || keycloakUser.id,
|
||||
email: keycloakUser.email,
|
||||
name: name,
|
||||
tier: keycloakUser.tier || 'basic', // From custom Keycloak attribute
|
||||
authSource: 'keycloak',
|
||||
raw: keycloakUser
|
||||
};
|
||||
}
|
||||
|
||||
// Fall back to Directus user
|
||||
// Only use Directus user for now
|
||||
if (directusUser.value && directusUser.value.email) {
|
||||
return {
|
||||
id: directusUser.value.id,
|
||||
|
|
@ -54,16 +29,11 @@ export const useUnifiedAuth = () => {
|
|||
return null;
|
||||
});
|
||||
|
||||
// Unified logout function
|
||||
// Unified logout function (Directus only)
|
||||
const logout = async () => {
|
||||
if (user.value?.authSource === 'keycloak') {
|
||||
// Keycloak logout
|
||||
await keycloak.logout();
|
||||
} else if (user.value?.authSource === 'directus') {
|
||||
// Directus logout
|
||||
await directusAuth.logout();
|
||||
await navigateTo('/login');
|
||||
}
|
||||
// Directus logout
|
||||
await directusAuth.logout();
|
||||
await navigateTo('/login');
|
||||
};
|
||||
|
||||
// Check if user is authenticated
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ export default defineNuxtRouteMiddleware(async (to) => {
|
|||
const isAuthRequired = to.meta.auth !== false;
|
||||
|
||||
try {
|
||||
// Check Directus auth first (more reliable)
|
||||
// Only use Directus auth for now (disable Keycloak temporarily)
|
||||
const { fetchUser, setUser } = useDirectusAuth();
|
||||
const directusUser = useDirectusUser();
|
||||
|
||||
|
|
@ -15,7 +15,10 @@ export default defineNuxtRouteMiddleware(async (to) => {
|
|||
const user = await fetchUser();
|
||||
setUser(user.value);
|
||||
} catch (error) {
|
||||
// Ignore directus auth errors
|
||||
// Ignore directus auth errors for public pages
|
||||
if (!isAuthRequired) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -24,25 +27,6 @@ export default defineNuxtRouteMiddleware(async (to) => {
|
|||
return;
|
||||
}
|
||||
|
||||
// Try Keycloak auth (only if we need it)
|
||||
if (isAuthRequired) {
|
||||
const keycloak = useKeycloak();
|
||||
|
||||
// Only try to initialize if not already done
|
||||
if (!keycloak.isInitialized.value) {
|
||||
try {
|
||||
await keycloak.initKeycloak();
|
||||
} catch (error) {
|
||||
console.error('Keycloak init failed:', error);
|
||||
}
|
||||
}
|
||||
|
||||
if (keycloak.isAuthenticated.value) {
|
||||
// User authenticated with Keycloak
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// No authentication found
|
||||
if (isAuthRequired) {
|
||||
// Redirect to login page
|
||||
|
|
|
|||
|
|
@ -10,27 +10,7 @@
|
|||
<v-img src="/Port_Nimara_Logo_2_Colour_New_Transparent.png" width="200" class="mb-3 mx-auto" />
|
||||
</v-col>
|
||||
|
||||
<!-- Keycloak SSO Login -->
|
||||
<v-col cols="12" class="mb-4">
|
||||
<v-btn
|
||||
color="primary"
|
||||
size="large"
|
||||
block
|
||||
@click="loginWithKeycloak"
|
||||
prepend-icon="mdi-shield-account"
|
||||
>
|
||||
Login with Single Sign-On
|
||||
</v-btn>
|
||||
</v-col>
|
||||
|
||||
<!-- Divider -->
|
||||
<v-col cols="12">
|
||||
<v-divider class="my-4">
|
||||
<span class="text-caption">OR</span>
|
||||
</v-divider>
|
||||
</v-col>
|
||||
|
||||
<!-- Existing Directus Login Form -->
|
||||
<!-- Directus Login Form -->
|
||||
<v-col cols="12">
|
||||
<v-form @submit.prevent="submit" v-model="valid">
|
||||
<v-row no-gutters>
|
||||
|
|
@ -111,12 +91,9 @@ definePageMeta({
|
|||
auth: false
|
||||
});
|
||||
|
||||
// Directus auth
|
||||
// Directus auth only
|
||||
const { login } = useDirectusAuth();
|
||||
|
||||
// Keycloak auth for SSO
|
||||
const keycloak = useKeycloak();
|
||||
|
||||
const loading = ref(false);
|
||||
const errorThrown = ref(false);
|
||||
|
||||
|
|
@ -126,12 +103,6 @@ const passwordVisible = ref(false);
|
|||
|
||||
const valid = ref(false);
|
||||
|
||||
// Keycloak login function
|
||||
const loginWithKeycloak = async () => {
|
||||
// Initialize and login with Keycloak
|
||||
await keycloak.login();
|
||||
};
|
||||
|
||||
// Directus login function
|
||||
const submit = async () => {
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in New Issue