-
Notifications
You must be signed in to change notification settings - Fork 462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'authenticated' event fires multiple times #44
Comments
Hey Max, I'm gonna look into this after front trends, sorry it takes so long |
btw, there is also a |
here is the code I have: hoodie.account.authenticate().then(function noop(){}, isLoggedOut)
hoodie.account.on('authenticated', isLoggedIn)
hoodie.account.on('signout', isLoggedOut) this works okay but it would be better if .on('authenticated') only fired On Sat, Apr 20, 2013 at 9:22 AM, Gregor Martynus
|
here's a list of account events (please give feedback if you'd suggest a name change, now is the time ;-):
I'd do the following: hoodie.account.authenticate().then(isLoggedIn, isLoggedOut)
hoodie.account.on('signin', isLoggedIn)
hoodie.account.on('signout', isLoggedOut) The reason why you get the |
ah so my dilemma is: when the app starts up it will trigger .on('authenticated') a bunch of
but if I rely on .signIn/.signOut it will only trigger when the user so, this is why I do this (now with more comments):
|
your comment again for better readablity, dunno what's happening with @github ah so my dilemma is: when the app starts up it will trigger .on('authenticated') a bunch of
but if I rely on .signIn/.signOut it will only trigger when the user so, this is why I do this (now with more comments):
|
ah weird, that was written from gmail, usually that works |
The The So, my suggestion would be, simply check if the user is currently logged in without checking the session: if (hoodie.account.username) {
// user is logged in
} else {
// user is not logged in
} and then, handle only the events when a user intentionally signes in or out, with
And then, there is the case when a user is signedIn as hoodie.account.username is set, but the session is not valid anymore. To handle that event, you can subscribe to
does that make sense? |
Ahhhhh, I see. I'll fix my code. Thanks! BTW I stole my code from a readme
|
Yeah, great idea, cheers! I've made an extra ticket to clarify things in general. |
when I have a
hoodie.account.on('authenticated'
listener it calls the callback 3 times when I dohoodie.account.authenticate
The text was updated successfully, but these errors were encountered: