Fix login path and logs

This commit is contained in:
2025-06-16 15:25:35 +02:00
parent b2fa29cdc6
commit ecce499127
2 changed files with 23 additions and 23 deletions

View File

@@ -45,7 +45,7 @@ onMounted(async () => {
}
// Wait 5 second to avoid race condition
await new Promise(resolve => setTimeout(resolve, 5000));
await new Promise(resolve => setTimeout(resolve, 2000));
message.value = 'Logging in to the application...';
// Token exchange function with retry
@@ -92,8 +92,8 @@ onMounted(async () => {
console.log('[Callback] No project selected, redirecting to projects-list');
router.push({ name: 'projects-list' });
} else {
console.log('[Callback] Project selected, redirecting to scenario-list');
router.push({ name: 'scenario-list' });
console.log('[Callback] Project selected, redirecting to ksdocuments');
router.push({ name: 'ksdocuments' });
}
} catch (fetchErr) {
console.error('[Callback] Error fetching user after token exchange:', fetchErr);

View File

@@ -64,7 +64,7 @@ const loginAD = async () => {
console.log('[loginAD] Token MSAL ottenuto:', token);
// Inserisci una pausa per evitare race condition
await new Promise(r => setTimeout(r, 5000));
await new Promise(r => setTimeout(r, 2000));
let exchangeResponse;
try {
@@ -82,34 +82,34 @@ const loginAD = async () => {
console.log('[loginAD] No project selected → projects-list');
router.push({ name: 'projects-list' });
} else {
console.log('[loginAD] Project selected → scenario-list');
router.push({ name: 'scenario-list' });
console.log('[loginAD] Project selected → ks-document');
router.push({ name: 'ks-document' });
}
} else {
console.error('[loginAD] Nessun token backend ricevuto:', exchangeResponse.data);
console.error('[loginAD] No backend token received:', exchangeResponse.data);
error.value = 'User not configured for this application. Contact the administrator.';
visible.value = true;
}
} catch (err) {
console.error('[loginAD] Errore su token exchange (dopo retry):', err.response?.data || err);
console.error('[loginAD] Error while exchanging token (after retry):', err.response?.data || err);
error.value = 'An error occurred during the token exchange. Please try again.';
visible.value = true;
}
} catch (e) {
console.error('[loginAD] Errore generale:', e);
error.value = "Errore durante il login AD. Contattare l'amministratore.";
console.error('[loginAD] Error:', e);
error.value = "Error while authenticating with Microsoft AD. Contact the administrator.";
visible.value = true;
}
};
const loginMsal = async () => {
console.log('[loginMsal] Avvio login MSAL redirect...');
console.log('[loginMsal] Start login MSAL redirect...');
try {
await msalInstance.initialize();
msalInstance.loginRedirect(msalrequest);
} catch (e) {
console.error('[loginMsal] Errore loginRedirect:', e);
error.value = 'Errore durante il login con Microsoft AD.';
console.error('[loginMsal] Error loginRedirect:', e);
error.value = 'Errore while login with Microsoft AD.';
visible.value = true;
}
};
@@ -122,17 +122,17 @@ const logoutAD = async () => {
};
try {
await msalInstance.logoutPopup(logoutRequest);
console.log('[logoutAD] Logout completato.');
console.log('[logoutAD] Logout completed.');
} catch (e) {
console.error('[logoutAD] Errore durante il logout:', e);
error.value = 'Errore durante il logout AD.';
console.error('[logoutAD] Errore while logout:', e);
error.value = 'Error while logout AD.';
visible.value = true;
}
};
const login_old = async () => {
console.log('[login_old] Login con username/password:', username.value);
console.log('[login_old] Login with username/password:', username.value);
try {
await auth
.login({
@@ -145,15 +145,15 @@ const login_old = async () => {
.then((response) => {
console.log('[login_old] Login response:', response.data.data);
if (!response.data.data.selectedProject) {
console.log('[login_old] Nessun progetto selezionato, redirect a projects-list');
console.log('[login_old] No selected project, redirect to projects-list');
router.push({ name: 'projects-list' });
} else {
console.log('[login_old] Progetto selezionato, redirect a scenario-list');
router.push({ name: 'scenario-list' });
console.log('[login_old] Project selected, redirect to ks-document');
router.push({ name: 'ks-document' });
}
})
.catch((err) => {
console.error('[login_old] Errore login:', err);
console.error('[login_old] Error login:', err);
error.value = 'Incorrect username or password. Please try again.';
visible.value = true;
setTimeout(() => {
@@ -161,8 +161,8 @@ const login_old = async () => {
}, 3500);
});
} catch (err) {
console.error('[login_old] Errore generale:', err);
error.value = 'Errore generico durante il login.';
console.error('[login_old] Error:', err);
error.value = 'Errore while login.';
visible.value = true;
}
};