BrowserId login request is called right at document loading

130 Views Asked by At

My browserId login code is almost verbatim from here. But when I open the Route, the request is sent automatically, no matter if loggedInEmail is set or anything else, and it results in an eternal refresh loop. My Javascript code is, when generated:

navigator.id.watch({
    'loggedInEmail': null,
    'onlogin': (function (jmId_1_0) {
        $.ajax({
            'data': {
                'assertion': jmId_1_0
            },
            'error': (function (jmId_1_1, jmId_1_2, jmId_1_3) {
                alert(("login failure" + jmId_1_1));
            }),
            'success': (function (jmId_1_4, jmId_1_5, jmId_1_6) {
                console.log(jmId_1_4);
            }),
            'type': "POST",
            'url': "\/login"
        });
    }),
    'onlogout': (function () {
        $.ajax({
            'error': (function (jmId_1_7, jmId_1_8, jmId_1_9) {
                alert(("logout failure" + jmId_1_7));
            }),
            'success': (function (jmId_1_10, jmId_1_11, jmId_1_12) {
                window.location.reload();
            }),
            'type': "POST",
            'url': "\/logout"
        });
    })
});
$((function () {
    $("#loginBtn").click((function (jmId_1_13) {
        jmId_1_13.preventDefault();
        navigator.id.request();
        return false;
    }));
}));

The onlogin functions is always called, no matter if the user clicked the button. It must be somewhere in browserId itself, or I did something fundamentally wrong.

Full template code can be found here.

1

There are 1 best solutions below

0
On

Seems like this problem was caused from an incorrect setting of loggedInEmail.