@@ -120,7 +120,7 @@ abstract class BaseFacebook
120120 /**
121121 * Version.
122122 */
123- const VERSION = '3.2.1 ' ;
123+ const VERSION = '3.2.2 ' ;
124124
125125 /**
126126 * Signed Request Algorithm.
@@ -367,20 +367,20 @@ public function setExtendedAccessToken() {
367367 // In any event, we don't have an access token, so say so.
368368 return false ;
369369 }
370-
370+
371371 if (empty ($ access_token_response )) {
372372 return false ;
373373 }
374-
374+
375375 $ response_params = array ();
376376 parse_str ($ access_token_response , $ response_params );
377-
377+
378378 if (!isset ($ response_params ['access_token ' ])) {
379379 return false ;
380380 }
381-
381+
382382 $ this ->destroySession ();
383-
383+
384384 $ this ->setPersistentData (
385385 'access_token ' , $ response_params ['access_token ' ]
386386 );
@@ -439,6 +439,11 @@ protected function getUserAccessToken() {
439439 // the JS SDK puts a code in with the redirect_uri of ''
440440 if (array_key_exists ('code ' , $ signed_request )) {
441441 $ code = $ signed_request ['code ' ];
442+ if ($ code && $ code == $ this ->getPersistentData ('code ' )) {
443+ // short-circuit if the code we have is the same as the one presented
444+ return $ this ->getPersistentData ('access_token ' );
445+ }
446+
442447 $ access_token = $ this ->getAccessTokenFromCode ($ code , '' );
443448 if ($ access_token ) {
444449 $ this ->setPersistentData ('code ' , $ code );
0 commit comments