Merged PR 171: Fix login logs

Fix login logs
This commit is contained in:
2025-06-16 16:00:20 +00:00
2 changed files with 19 additions and 19 deletions

View File

@@ -44,8 +44,8 @@ onMounted(async () => {
localStorage.setItem('msalUser', JSON.stringify(response.account));
}
// Wait 5 second to avoid race condition
await new Promise(resolve => setTimeout(resolve, 5000));
// Wait 2 second to avoid race condition
await new Promise(resolve => setTimeout(resolve, 2000));
message.value = 'Logging in to the application...';
// Token exchange function with retry

View File

@@ -63,7 +63,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 {
@@ -85,30 +85,30 @@ const loginAD = async () => {
router.push({ name: 'scenario-list' });
}
} 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 on token exchange (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 login 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 = 'Error while login with Microsoft AD.';
visible.value = true;
}
};
@@ -121,16 +121,16 @@ 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] Error 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({
@@ -143,15 +143,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 project selected, redirect to projects-list');
router.push({ name: 'projects-list' });
} else {
console.log('[login_old] Progetto selezionato, redirect a scenario-list');
console.log('[login_old] Project selected, redirect to scenario-list');
router.push({ name: 'scenario-list' });
}
})
.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(() => {
@@ -159,8 +159,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 = 'Error while login.';
visible.value = true;
}
};