bertrando / facebook-actionscript-api

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

Clicking cancel on the AIR login window does not close the window #173

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create an AIR application with a login button
2. Click login so that the Login window pops up
3. Click cancel.

What is the expected output?
The window should close with your loginCallback being fired with a failure.

What do you see instead?
The page redirects within the Login window and then cannot be closed without 
errors.

What version of the product are you using?
Graph

Please provide any additional information below.
You can fix this by applying the attached patch.

Original issue reported on code.google.com by yourpalm...@gmail.com on 12 Oct 2010 at 3:15

Attachments:

GoogleCodeExporter commented 9 years ago
The patch for this bug included in the comments above will be addressed in the 
next build of the Facebook API.

Original comment by edwar...@gmail.com on 9 Nov 2010 at 9:03

GoogleCodeExporter commented 9 years ago
When I click the cancel button, the value of html.location is equal to 
"http://www.facebook.com/connect/login_success.html".  Hence there are no 
parameters which creates a null pointer exception when the function 
loginCallback(getURLVariables(), null); is called.  

To get around this, I added a check on the params variable in the 
AbstractWindow class.  If null, I return.  Then in LoginWindow, I check if the 
URLVariables is null and, if so, call the corresponding close functions:

LoginWindow.as

override protected function handleLocationChange(event:Event):void {
            super.handleLocationChange(event);
            if (html.location.indexOf(
                'http://www.facebook.com/connect/login_success.html?error_reason'
            ) == 0) {
                loginCallback(null, getURLVariables().error_reason);
            } else if (html.location.indexOf (
                    'http://www.facebook.com/connect/login_success.html'
                    ) == 0)
            {

                //SS fix - added check for null parms
                var parms:URLVariables = getURLVariables();
                if(parms != null) {
                    loginCallback(getURLVariables(), null);
                }

                userClosedWindow =  false;
                html.stage.nativeWindow.close();

            } else if (html.location.indexOf(
                'https://login.facebook.com/login.php'
                    ) == 0)
            { 
                showDistractor();
        } else if (html.location.indexOf(
            'https://graph.facebook.com/oauth/authorize_cancel'
            ) == 0)
            {
                loginCallback(false, 'user-canceled');
                    html.stage.nativeWindow.close();
            }

        }

AbstractWindow.as
protected function getURLVariables():URLVariables {
      var params:String;
      if (html.location.indexOf('#') != -1) {
        params = html.location.slice(html.location.indexOf('#')+1);
      } else if (html.location.indexOf('?') != -1) {
        params = html.location.slice(html.location.indexOf('?')+1);
      }

      //SS fix:  added check for null parms and then returns if true
      if(params == null) {
          return null;
      }

        var vars:URLVariables = new URLVariables();
        vars.decode(params);

      return vars;
    }

Original comment by john.ant...@gmail.com on 15 Nov 2010 at 11:59

GoogleCodeExporter commented 9 years ago

Original comment by edwar...@gmail.com on 6 Dec 2010 at 10:24

GoogleCodeExporter commented 9 years ago
Hey ive used the code you have provided but yet i still have the problem , when 
i click cancel the login window still stays on the screen i have to force quit 
the program to get it off the screen

LoginWindow.as

override protected function handleLocationChange(event:Event):void {
            super.handleLocationChange(event);

            if (html.location.indexOf(
                'http://www.facebook.com/connect/login_success.html?error_reason') == 0) {
                loginCallback(null, getURLVariables().error_reason);    
            }       
            else if (html.location.indexOf ('http://www.facebook.com/connect/login_success.html') == 0)
            {
                //SS fix - added check for null parms
                var parms:URLVariables = getURLVariables();
                if(parms != null) {
                    loginCallback(getURLVariables(), null);
                }

                userClosedWindow =  false;
                html.stage.nativeWindow.close();    
            } 
            else if (html.location.indexOf('https://login.facebook.com/login.php') == 0)
            { 
                showDistractor();
            } 

        else if (html.location.indexOf('https://graph.facebook.com/oauth/authorize_cancel') == 0)
                        {
                            loginCallback(false, 'user-canceled');

                                html.stage.nativeWindow.close();
                        }
                  }

AbstractWindow.as

protected function getURLVariables():URLVariables {
        var params:String;
        if (html.location.indexOf('#') != -1) {
            params = html.location.slice(html.location.indexOf('#')+1);
        } else if (html.location.indexOf('?') != -1) {
            params = html.location.slice(html.location.indexOf('?')+1);
        }

        //SS fix:  added check for null parms and then returns if true
        if(params == null) {
            return null;
        }

        var vars:URLVariables = new URLVariables();
        vars.decode(params);
        if (params) {
            vars.decode(params);
        }
        return vars;
    }

Original comment by sarah.de...@gmail.com on 7 Feb 2011 at 9:24

GoogleCodeExporter commented 9 years ago
It sounds like you may be using an older build of the SDK, this issue should 
already be resolved using the latest version (1.6)

Original comment by edwar...@gmail.com on 9 Mar 2011 at 9:11