Custom Logout Button on Dashboard

Hello Team Helical,

I am giving dashboards in read only mode to end users. I want to add a custom logout button on the dashboard itself so that they can click on it and logout. They don’t have to login to the application. How can that be done?

Hello Shwetant,

There is an API which you can trigger which automatically logs out the user which is “j_spring_security_logout”. In Helical Insight if you add it to the base URL you can see the logging out action getting triggered.

In your dashboard you can add an image by right-clicking and on that image you can define a click action by right clicking on it and going to JS portion of it. By clicking on it you will have to trigger the below API. The component id inside $() will change according to your usage.

$("#jvklc8cutx").on('click',function(){
window.open(window.baseUrl+"j_spring_security_logout",'_self');
});

Via CSS you can define the look and feel of the button and on hover action.

image

Thank You
Helical Insight Team.

LogOut API using AJAX
If you would like to use AJAX to trigger logout below is the method of how the same can be done.

function logout()
{
	$.ajax({
	    type: "GET",
	    url:url+"j_spring_security_logout",
	    xhrFields: { withCredentials: true },
		crossDomain: true,
		dataType: 'jsonp',
	    success: function(data) 
	    {
	    	alert("Logout successfully");
	    }, 
	    error: function(data)
	    {
			// alert("Logout Error");
	    	//alert("Logout successfully");
	    }
	});
}