Commit fccffb4e authored by jan.koester's avatar jan.koester
Browse files

test

parent 9792b5f1
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -170,6 +170,12 @@
        var errBox = document.getElementById('login-error');
        var btn = document.getElementById('login-btn');

        // Derive the mount prefix from the current location so login works both
        // at the domain root and behind a proxy prefix (e.g. /editor). Strips a
        // trailing slash and an optional /login or /login.html suffix.
        var basePath = window.location.pathname
            .replace(/\/(login|login\.html|index\.html)?$/, '');

        form.addEventListener('submit', function(e) {
            e.preventDefault();
            errBox.style.display = 'none';
@@ -177,7 +183,7 @@
            btn.textContent = I18n.t('Loading...', 'Signing in...');

            var xhr = new XMLHttpRequest();
            xhr.open('POST', '/api/login', true);
            xhr.open('POST', basePath + '/api/login', true);
            xhr.setRequestHeader('Content-Type', 'application/json');
            xhr.onreadystatechange = function() {
                if (xhr.readyState !== 4) return;
@@ -185,7 +191,7 @@
                btn.textContent = I18n.t('Submit', 'Sign in');

                if (xhr.status === 200) {
                    window.location.href = '/';
                    window.location.href = basePath + '/';
                } else {
                    try {
                        var resp = JSON.parse(xhr.responseText);