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


#1

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.


#2

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.


#3

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


#4

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.


#5

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


#6

Decided to use:

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

instead of controller and this works.


#7

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.


#8

@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