AnthonyLins / facebook-actionscript-api

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

Clicking Facebook's Cancel button on first login causes runtime error #385

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Use FacebookMobile
2. On the first ever login by a user, you are presented with a web page in the 
StageWebView that has a "Cancel" button on the left, and a "Log In" button on 
the right (see attached image)
3. Clicking the Cancel button causes the following RTE

TypeError: Error #1009: Cannot access a property or method of a null object 
reference.
    at com.facebook.graph::FacebookMobile/handleLogin()[C:\Users\facebookGraphApi\mobileAPI\com\facebook\graph\FacebookMobile.as:569]
    at com.facebook.graph.windows::MobileLoginWindow/handleLocationChange()[C:\Users\facebookGraphApi\mobileAPI\com\facebook\graph\windows\MobileLoginWindow.as:146]

What version of the product are you using? 
1.8.1

Original issue reported on code.google.com by jamie...@insightbb.com on 28 Nov 2011 at 11:33

Attachments:

GoogleCodeExporter commented 8 years ago
Note that this "App Login" webpage is what shows up after you enter your email 
address and password for the very first time.  This is where you are 
authorizing the app for whatever permissions it is requesting.

Original comment by jamie...@insightbb.com on 29 Nov 2011 at 12:29

GoogleCodeExporter commented 8 years ago
I dug a little more into this.  The problem is that both the result and fail 
objects are null when passed to FacebookMobile.handleLogin(result:Object, 
fail:Object)

The fail object should not be null in this case. It is null, because of line 
#146 in MobileLoginWindow.handleLocationChange()

    loginCallback(null, FacebookDataUtils.getURLVariables(location).error_reason);

The FacebookDataUtils.getURLVariables() method is being sent the following URL, 
which causes a problem:

http://www.facebook.com/connect/login_success.html?error_reason=user_denied&erro
r=access_denied&error_description=The+user+denied+your+request.#_=_

FacebookDataUtils.getURLVariables() returns an instance of URLVariables with 
just one property (see attached image).

The way I fixed it was to reverse the order of the if else statement in 
FacebookDataUtils.getURLVariables

Changed this:

    if (url.indexOf('#') != -1) {
        params = url.slice(url.indexOf('#')+1);
    } else if (url.indexOf('?') != -1) {
        params = url.slice(url.indexOf('?')+1);
    }

To this:

    if (url.indexOf('?') != -1)
        params = url.slice(url.indexOf('?') + 1);
    else if (url.indexOf('#') != -1)
        params = url.slice(url.indexOf('#') + 1);

That avoids the run time error and the method now returns a correct 
URLVariables instance (see attached image).  There may be a better fix, however.

One thing that is still an issue, though, is that when the user clicks that 
Cancel button, they can never get back to the first login screen where it asks 
for the email address and password.  Even if you call logout().  And sometimes 
it even shows the Facebook home page http://www.facebook.com/home.php

To get back to the original login screen, they have to click the "Log In" 
button and authorize the app.  Then they can successfully logout.

Original comment by jamie...@insightbb.com on 29 Nov 2011 at 5:03

Attachments:

GoogleCodeExporter commented 8 years ago
someone compile the patched version? i have the same problem :(

Original comment by magc...@gmail.com on 21 Mar 2012 at 7:37

GoogleCodeExporter commented 8 years ago
Here is the compiled swc with the fix I posted in comment #1.

Original comment by jamie...@insightbb.com on 21 Mar 2012 at 8:48

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks, I was getting the same error on "cancel", but you are correct, 
sometimes after cancel it does hang or redirects to another facebook page.  
Have you seen or heard any updates?

Original comment by lbar...@thesminc.com on 26 Mar 2012 at 5:56

GoogleCodeExporter commented 8 years ago
I get this url returned "http://m.facebook.com/home.php?refid=0&_rdr" .  
handleLocationChange in MobileLoginWindow.as checks url's established in 
FacebookURLDefaults.as. By adding that url in FacebookURLDefaults.as or check 
for it in handleLocationChange., it seemed to allow multiple cancels and allows 
you to properly login

Original comment by lbar...@thesminc.com on 26 Mar 2012 at 9:59