Custom Logout event

Hi to all,

I would like to customize the logout function for the task list.
After logout, I’d like to go to the SSO page.

I need to change redirect URL to URL my SSO.

For the moment, I’m using a custom camunda-webapp package.

To solve the problem, I tried to use the custom script (
but failed.

I ask for help in solving this task.


I managed to connect a custom script.
When i use the custom button, the script runs successfully.
But unfortunately it is not called when logout when I use the default button (from component camunda-commons-ui)

'use strict';
define('custom-ng-module', [
], function (angular) {
    var customModule = angular.module('my.custom.module', []);

    customModule.controller('camHeaderViewsCtrl', ['scope', function ($scope) {
        $rootScope.logout = function (){

    return customModule;

Could you help me to override the default script for my custom script?

Hi @petrovtsev, you can achieve that by doing the following:

  customModule.controller('camHeaderViewsCtrl', ['$window', '$scope', function($window, $scope) {
    // isLoggedIn: flag set to true initially, since user is logged in
    var isLoggedIn = true;
    // register listener to 'authentication.changed' event
    var listener = $scope.$root.$on('authentication.changed', function(ev, auth) {
      if(!auth && isLoggedIn) {
        isLoggedIn = false;

    // remove listener to 'authentication.changed' event
    $scope.$on('$destroy', function() {


  return customModule;

Does this help you? Please let me know if you have any questions regarding this.

Hi @petrovtsev ,

Were you able to write the scripts for Custom logout ?

If yes,Could you please provide a Sample.

1 Like

Hi @siffogh,

is that script supposed to run without any custom buttons (i.e. using the default logout button in the web app)? I tried adding it and registering it as in the doc and it doesn’t seem to be called at all


1 Like

Hi there,
I’ve got the same problem. Is there anyone with a solution? I know nothing about Angular… It feel that it can’t be that hard to change such a simple behaviour. But I just don’t know how…

Got it. A bit hacky but it works.

'use strict';
define('custom-logout', ['angular'], function (angular) {
    var customLogoutModule = angular.module('custom-logout', []).run(
        ['$rootScope', function ($rootScope) {

            $rootScope.$on('$viewContentLoaded', function (event) {
                // Get the HTML element of the header widget.
                var div = document.querySelector("[cam-widget-header]");

                // Get the only property on it, its key is jQuery<many numbers> and its value
                // contains the controller ($camWidgetHeaderController) and the isolated
                // Scope ($isolateScope). The logout function is defined in this scope.
                var jQueryKey = Object.getOwnPropertyNames(div)[0];
                var $isolateScope = div[jQueryKey]['$isolateScope'];
                $isolateScope.logout = function () {
                    // Do whatever you want to do on logout.
                    window.location.href = "/logout"