File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ function login() {
22 const name = document . getElementById ( 'name' ) . value . trim ( ) ;
33 const email = document . getElementById ( 'email' ) . value . trim ( ) ;
44
5- // Accetta qualsiasi nome/email, ma suggeriamo di non lasciare vuoti
5+ // Fake login
66 if ( ! name || ! email ) {
77 alert ( 'Inserisci nome ed email.' ) ;
88 return ;
@@ -14,4 +14,26 @@ function login() {
1414
1515 // Reindirizza alla welcome
1616 window . location . href = 'welcome.html' ;
17+ }
18+
19+ // --- FUNZIONE LOGOUT ---
20+ function logout ( ) {
21+ // 1. Pulizia Salesforce (Sessione Chat)
22+ // Usiamo un try-catch per evitare errori se la funzione viene chiamata dove la chat non c'è
23+ try {
24+ // Controlliamo se l'oggetto Salesforce esiste in questa pagina
25+ if ( typeof embeddedservice_bootstrap !== 'undefined' && embeddedservice_bootstrap . utilAPI ) {
26+ embeddedservice_bootstrap . utilAPI . clearSession ( ) ;
27+ console . log ( "Sessione Salesforce terminata." ) ;
28+ }
29+ } catch ( err ) {
30+ console . log ( "Nessuna sessione Salesforce attiva da chiudere o API non disponibile." ) ;
31+ }
32+
33+ // 2. Pulizia Memoria Locale (I tuoi dati)
34+ localStorage . removeItem ( 'name' ) ;
35+ localStorage . removeItem ( 'email' ) ;
36+
37+ // 3. Reindirizzamento al Login
38+ window . location . href = 'index.html' ;
1739}
Original file line number Diff line number Diff line change @@ -21,6 +21,12 @@ <h1 id="welcome-message">Benvenuto!</h1>
2121 < p class ="email " id ="email-line "> </ p >
2222
2323 < a id ="btn-open-chat " class ="button disabled "> Caricamento Chat...</ a >
24+ < div style ="margin-top: 20px; border-top: 1px solid #eee; padding-top: 15px; ">
25+ < button onclick ="logout() " style ="background: none; border: none; color: #dc3545; cursor: pointer; text-decoration: underline; font-size: 14px; ">
26+ Esci e cambia utente
27+ </ button >
28+ </ div >
29+
2430 </ div >
2531
2632 < script >
You can’t perform that action at this time.
0 commit comments