summaryrefslogtreecommitdiffstats
path: root/application/views/scripts/authentication/logout.phtml
blob: d4bd78e01bf6273e24dd6807d97be372b3a0c1db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<!--
    This view provides a workaround to logout from an external authentication provider, in case external
    authentication was configured (the default is to handle authentications internally in Icingaweb2).

    The <a href="http://tools.ietf.org/html/rfc2617">Http Basic and Digest Authentication</a> is not
    designed to handle logout. When the user has provided valid credentials, the client is adviced to include these
    in every further request until the browser was closed. To allow logout and to allow the user to change the
    logged-in user this JavaScript provides a workaround to force a new authentication prompt in most browsers.
-->
<div class="content">
    <div id="icinga-logo" aria-hidden="true"></div>
    <div class="alert alert-warning" id="logout-status">
        <b><?= $this->translate('Logging out...'); ?></b>
        <br>
        <?= $this->translate(
            'If this message does not disappear, it might be necessary to quit the'
            . ' current session manually by clearing the cache, or by closing the current'
            . ' browser session.'
        ); ?>
    </div>

    <div class="container">
        <a href="<?= $this->href('dashboard'); ?>"><?= $this->translate('Login'); ?></a>
    </div>
</div>
<script type="text/javascript">
    /*
     * When JavaScript is available, trigger an XmlHTTPRequest with the non-existing user 'logout' and abort it
     * before it is able to finish. This will cause the browser to show a new authentication prompt in the next
     * request.
     */
    document.addEventListener('DOMContentLoaded', function () {
        var msg = document.getElementById('logout-status');
        try {
            if (navigator.userAgent.toLowerCase().indexOf('msie') !== -1) {
                document.execCommand('ClearAuthenticationCache');
            } else {
                var xhttp = new XMLHttpRequest();
                xhttp.open('GET', 'arbitrary url', true, 'logout', 'logout');
                xhttp.send('');
                xhttp.abort();
            }
        } catch (e) {
        }
        msg.innerHTML = '<?= $this->translate('Logout successful!'); ?>';
        msg.className = 'alert alert-success';
    });
</script>
<style type="text/css">
    body {
        font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
        background-color: #0095bf;
        color: white;
    }
    .content {
        text-align: center;
    }

    #icinga-logo {
        background-image: url('../img/icinga-logo-big.svg');
        background-position: center bottom;
        background-repeat: no-repeat;
        background-size: contain;
        height: 177px;
        margin-top: 10em;
        width: 100%;
    }

    #logout-status {
        margin: 2em 0 1em;
        font-size: 2em;
        font-weight: bold;
    }

    .container a {
        color: white;
        font-size: 1.5em;
    }
</style>