Cannot change logout action in Welcome/Admin, works in Tasklist/Cockpit

I need to modify my springboot camunda webapp deployment so that it redirects browser to different web after logout. I managed to do so for Cockpit and Tasklist, but in the Welcome and Admin screens it’s not working for some reason.
I’ve added following customScript to all of these application:

define(['angular'], function(angular) {
console.log('SCRIPT INITED');
var ngModule = angular.module('ssoLogout', []);
ngModule.controller('camHeaderViewsCtrl', ['$window', '$scope', function($window, $scope) {
    console.log('SCRIPT LOADED');
    var isLoggedIn = true;
    var listener = $scope.$root.$on('authentication.changed', function(ev, auth) {
        console.log('Authentication changed');
        if(!auth && isLoggedIn) {
            console.log('logout');
            window.location.replace("http://myssoredirect.com");
        }
    });
    // remove listener to 'authentication.changed' event
    $scope.$on('$destroy', function() {
        listener();
    });
}]);
return ngModule;

});

I know the script is loaded on each of these pages, because I get SCRIPT INITED in the console, but I get the next log SCRIPT LOADED only in Cockpit and Tasklit screens.

I don’t know a lot about angular so I don’t know how to debug this. Is the camHeaderViewsCtrl only in two of these application?
Maybe there’s some better way to add the custom scripts so I don’t have to modify each application separately.

After studying the sources, it seems there’s no camHeaderViewsCtrl in the Welcome and Admin pages. In Admin page, the controller is called “NavigationController” and in the Welcome page, the controller is “WelcomePage”. After modifying the scripts, my logout action works.

Hi @neplatnyudaj

Have you noticed that by using your implementation the navigation for Cockpit disappears? Using camHeaderViewsCtrl seems to remove the navigation header in Cockpit. Have you experienced this?

Thanks

Hi. It seems we’re doing the same thing. I’ve created a separate script for each app and seems to be working.
And btw I have the same problem with logout redirect which you are solving in another thread. But for me it’s not a big deal since it won’t be used by end-user.

Hi @neplatnyudaj I’ve created separate scripts as well but on Cockpit it loses the navigation menu. Strange. Do you have an example of your config.js for cockpit?

Thanks

Decided to use:

ngModule.run(function($window, $rootScope)

instead of controller and this works.

Here’s how I’m doing it: https://github.com/neplatnyudaj/camundaSSO/tree/master/resources/webjars/camunda/app

There’s a bit of a hack with setting the correct ssoUrl through authentications.

@neplatnyudaj Thanks for sharing your js files. Must be a version issue which means if I use the controller it replaces the navigation. The run approach works for me.

Thanks for your help.

Cheers

What do you mean by “There’s a bit of a hack with setting the correct ssoUrl through authentications”?

I can’t seem to get the Cockpit to ssoLogout. Admin and Tasklist work fine, but Cockpit doesn’t load my customScript paths. I have a very similar approach to your code. If I stick a break point on window.camCockpitConf it breaks but the ssoLogout.js path isn’t loaded in the browser like it is for Admin and Tasklist, which basically have the same code/approach as Cockpit. I’ve noticed there are structural differences with Cockpit (different image directory, facvicon.ico is in a different place).