Fix login logs

This commit is contained in:
2025-06-16 17:53:34 +02:00
parent 0b3f04febd
commit bcf162e72f
2 changed files with 19 additions and 19 deletions

View File

@@ -44,8 +44,8 @@ onMounted(async () => {
localStorage.setItem('msalUser', JSON.stringify(response.account)); localStorage.setItem('msalUser', JSON.stringify(response.account));
} }
// Wait 5 second to avoid race condition // Wait 2 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

View File

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