문제

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: "vansanblch@gmail.com",
    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()?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top