Show TOC

Creating a Custom Logout PageLocate this document in the navigation structure

SAP Web Dispatcher logout rules are used with a custom logout page to make sure that all system sessions are closed when logging out of SAP Fiori launchpad.

Context

Adapt the following:

Procedure

  1. Create an HTML file logout.html as in the example below. The logout page URL must use SAP Web Dispatcher as its origin.
  2. For each ABAP system from which you want to log out, add a requestLogout call with the logout URL matching the rule configured on the SAP Web Dispatcher:
    requestLogout(“sap;o=<ABAP System ID>/public/bc/icf/logoff”); 
  3. For each SAP HANA system from which you want to log out, call requestHanaLogout with the system ID from the corresponding SAP Web Dispatcher rule as parameter:
    requestHanaLogout("<HANA System ID>"); 
  4. Redirect to the actual logout page:
    document.location = <Your logout page>

Example

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <!-- Instead of this, you may include a jQuery version from your internal network if available-->

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
</head>
<body>
    <em id="message">Logout is in progress...</em>
    <script>
    (function () {
        "use strict";
        /*global document, jQuery*/
        var iPending = 0;
 
        function finishLogout() {
            iPending -= 1;
            if (iPending <= 0) { //logout done for all URLs
                //Change message text on logout page
                document.getElementById("message").innerHTML = "You are logged out";
                //(3) Client-side redirect
                document.location = "http://www.sap.com"; //REPLACE with your actual logout page

            }
        }

        function requestHanaLogout(sSystem) {
            iPending += 1;
            jQuery.ajax({
                type: "HEAD",
                url: "/sap;o=" + sSystem + "/hana/xs/formLogin/token.xsjs",
                headers: {
                    "X-CSRF-Token": "Fetch"
                },
            }).done(function (oData, oStatus, oXhr) {
                jQuery.ajax({
                    type: "POST",
                    url:  "/sap;o=" + sSystem + "/hana/xs/formLogin/logout.xscfunc",
                    headers: {
                        "X-CSRF-Token": oXhr.getResponseHeader("X-CSRF-Token")
                    }
                }).always(finishLogout);
            }).fail(finishLogout);
        } 

        function requestLogout(sUrl) {
            iPending += 1;
            jQuery.get(sUrl).always(finishLogout);
        }
 
        //(1) ABAP platform: Add such a line for each system with the corresponding logout URL
        requestLogout("/sap;o=<ABAP system ID>/public/bc/icf/logoff");

      
        //(2) SAP HANA platform: Add such a line for each system with the system ID from the Web Dispatcher rule
        requestHanaLogout("<HANA system ID>");

    }());
    </script>
</body>
</html>