Joget DX 8 Stable Released
The stable release for Joget DX 8 is now available, with a focus on UX and Governance.
#1 Javascript Approach
User clicks the joget generic logout button OR
We'll be using a script that will:
Insert the provided script into the Custom Javascript field in the UI Builder advanced settings:
Script:
$(document).ready(function(){ logoutBtn = $('a[href="/jw/j_spring_security_logout"'); $.each(logoutBtn, (k,v)=>{ console.log($(v)); $(v).on('click', function(e){ e.preventDefault(); //Logout current app window.location.href = "http://localhost:8080/jw/j_spring_security_logout"; //API Logout window.location.href = "https://{hostname}/api/login/logout"; }) }) })
Additionally,
If you do not want to receive the following alert:
Use this script instead
window.addEventListener("beforeunload",function (event){ event.stopImmediatePropagation(); }) $(document).ready(function(){ logoutBtn = $('a[href="/jw/j_spring_security_logout"'); $.each(logoutBtn, (k,v)=>{ console.log($(v)); $(v).on('click', function(e){ e.preventDefault(); //Logout current app window.location.href = "http://localhost:8080/jw/j_spring_security_logout"; //API Logout window.location.href = "https://{hostname}/api/login/logout"; }) }) })
The script will inform the browser not to execute any other "beforeunload" event handlers once this one is triggered.
Keep in mind that using stopImmediatePropagation in this context can have side effects. If there are other tasks or clean-up operations you need to perform when the page is unloaded, they will be skipped. It's important to consider the broader context of your application and whether this behavior aligns with your goals.
Reference:
https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event