kennylerma / facebook-actionscript-api

Automatically exported from code.google.com/p/facebook-actionscript-api
0 stars 0 forks source link

Initialize then login superfluous callback #388

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Use API in lazy load manner
2. Do NOT be logged into facebook currently
3. First time user tries to do facebook action (e.g. post), initialize 
(Facebook.init). Callback will indicate user not logged in.
4. If user not logged in, start login (Facebook.login)

What is the expected output? What do you see instead?
Would expect the login callback to be invoked once when login popup dismissed.

Instead, receive an immediate callback with no success or error object (similar 
to login 'cancel').

What version of the product are you using? On what operating system?
Version 1.8.1

Please provide any additional information below.
The issue is lies in Facebook.handleAuthResponseChange.
1. Facebook.init is called which sets _initCallback
2. That calls FBAS.init
3. The js calls back invoking Facebook.handleAuthResponseChange
4. The _initCallback is set so it is called
* Here is where the issue arises
5. The code path for the _initCallback checks the auth response and if no user, 
attempts to login
6. We try to login (Facebook.login) which sets _loginCallback
7. That calls FBAS.login
8. The AVM interrupts the async callback and we continue the code path in 
Facebook.handleAuthResponseChange
9. It checks _loginCallback and invokes if set - which it is. We incur a 
premature login callback with the init auth response.

Could simply be remedied by:
1. Moving the _loginCallback check before the _initCallback check in 
Facebook.handleAuthResponseChange.
2. Changing the _loginCallback check to "else if" and adding to the 
_initCallback logic. Could not think of a reason they would ever both be set. I 
did not exhaust many use cases though.

Original issue reported on code.google.com by reverend...@gmail.com on 29 Nov 2011 at 4:47