Commit 4cf9af08 authored by jan.koester's avatar jan.koester
Browse files

test

parent 388e37c7
Loading
Loading
Loading
Loading
+6 −8
Original line number Diff line number Diff line
@@ -190,12 +190,6 @@
        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';
@@ -203,7 +197,9 @@
            btn.textContent = I18n.t('Loading...', 'Signing in...');

            var xhr = new XMLHttpRequest();
            xhr.open('POST', basePath + '/api/login', true);
            // Relative URL — resolved against the <base href> set in <head>, so
            // it targets /editor/api/login behind a prefix or /api/login at root.
            xhr.open('POST', 'api/login', true);
            xhr.setRequestHeader('Content-Type', 'application/json');
            xhr.onreadystatechange = function() {
                if (xhr.readyState !== 4) return;
@@ -211,7 +207,9 @@
                btn.textContent = I18n.t('Submit', 'Sign in');

                if (xhr.status === 200) {
                    window.location.href = basePath + '/';
                    // Navigate to the mount root (the <base href>), not the
                    // domain root, so we stay inside the /editor prefix.
                    window.location.href = document.baseURI;
                } else {
                    try {
                        var resp = JSON.parse(xhr.responseText);