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