Javascript login request url

This may seem uninteresting, but I can’t find a way to do this, which is not considered a security issue (other than the obvious ways) ...

So, I want to create an add-on for Firefox for use with my team. Basically it will be a status bar icon, allowing us to find out if the cookie has expired to check the tools on our website, so we can say without losing any work in the browser.

At first I thought I could add a cookie add-on, but this seems like a huge problem for such a simple idea. Then it occurred to me ... DUH ... that I could just add to try to access the main page of our site. If he receives a "Denied access" response, he may display a "Do not log in" icon, but if he receives something else, he may display a "Signature".

However, all attempts to do this using AJAX turned out to be almost as difficult as trying my cookie.

Is there an easy way, preferably with javascript, but in XUL say otherwise

var url = "http://example.com";
var response = pingURL(url, "blah);
status = (response = "Welcome!") ? "Signed in" : "Not Signed In";

where "pingURL" will be the method of "navigating" to the url and receiving a response?

+1
source share
2

, - ? , , , , . . , , cookie.

0
function checkAccess(url, callback) {
    var xhr = new XMLHttpRequest();
    xhr.open("GET", url);
    xhr.onreadystatechange = function () {
        if (xhr.readyState == 4) {
            if (xhr.status == 200) {
                callback(true);
            } else {
                callback(false);
            }
        }
    };
}

... "checkAccess (' http://example.com', function (ready) {});" , ready .

+2

Source: https://habr.com/ru/post/1708018/


All Articles