Calling onlogin even for authenticated email

43 views Asked by At

I want to try Mozilla Persona in my recent project but found one unpleasant feature.

I hardcoded email-address in navigator.id.watch like this:

navigator.id.watch({
    loggedInUser: "[email protected]",
    onlogin: function () {
        console.log("onlogin");
    },
    onlogout: function () {
        console.log("onlogout");
    },
});

Then I call navigator.id.request() and enter my credentials to pass authentication. In developers API (about navigator.id.watch) it is said that if loggedInUser equal to state from Persona then no callbacks will be called.

But why I have "onlogin" message in console every single time I call navigator.id.request()?

1

There are 1 answers

0
Callahad On BEST ANSWER

That's happening because you found a corner case that Persona isn't handling. Oops.

The Persona team needs to sit down and figure out what should happen when you do that. I've filed a bug to track that discussion: https://github.com/mozilla/browserid/issues/3332

I'd appreciate it if you could chime in with what you think the correct behavior should be, and why.

For context, Persona initially used loggedInUser only for determining what callbacks to invoke automatically during page load. After that, it was more or less ignored. Which is why you're seeing calls to onlogin, even though the selected identity matches the current identity.