Skip to content

Commit

Permalink
Changed the way we auth a bit. added a logout option to the lib.
Browse files Browse the repository at this point in the history
  • Loading branch information
jubishop committed Jul 7, 2009
1 parent 8c3769e commit e79312a
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 8 deletions.
2 changes: 1 addition & 1 deletion fb/FBAPI.as
Expand Up @@ -37,7 +37,7 @@ package fb {

public class FBAPI {
private static const restURL:String =
"http://api.facebook.com/restserver.php";
"http://api.jubishop.devrs006.facebook.com/restserver.php";

private static var auth_token:String;
private static var session_key:String;
Expand Down
24 changes: 22 additions & 2 deletions fb/FBConnect.as
Expand Up @@ -63,7 +63,7 @@ package fb {
'publish_stream',
'auto_publish_short_feed'
];
private static var permissions:Array = new Array();;
private static var permissions:Array = new Array();
private static var validating_permissions:Array;

// Local filestorage (desktop "cookie")
Expand Down Expand Up @@ -119,7 +119,7 @@ package fb {
if (validating_permissions) return;

// Ask about all these first, to see if we're already auth'd
dispatcher.dispatchEvent(new FBEvent(FBEvent.ALERT,
dispatcher.dispatchEvent(new FBEvent(FBEvent.ALERT,
"Checking Extended Permissions"));
validating_permissions = permission_names;
FBAPI.callMethod("fql.query", {
Expand Down Expand Up @@ -266,11 +266,31 @@ package fb {
sharedObject.data["secret"] = session.secret;

status = Connected;

Output.log("Loaded session from login dialog: ",
session.key, session.uid, session.expires, session.secret);
} else {
status = NotLoggedIn;
}
}

// This will log us out if we have a session
public static function logout():void {
if (!api_key) return;

if (status == Connected) {
var expiration:JSONLoader = FBAPI.callMethod("auth.expireSession");
expiration.addEventListener(FBEvent.SUCCESS, loggedOutUser);
expiration.addEventListener(FBEvent.FAILURE, loggedOutUser);
} else loggedOutUser();
}

// Callback from restserver of when session is dead
private static function loggedOutUser(event:FBEvent = null):void {
session = null;
status = NotLoggedIn;
}

// Called internally when we've discovered we're unauthenticated
private static function unauthenticated():void {
validating_permissions = null;
Expand Down
2 changes: 1 addition & 1 deletion fb/display/FBDialog.mxml
Expand Up @@ -61,7 +61,7 @@
private static const MINIMUM_HEIGHT:int = 8;
public static const FacebookURL:String =
"http://www.facebook.com";
"http://www.jubishop.devrs006.facebook.com";
public static const NextPath:String = FacebookURL +
"/connect/login_success.html";
Expand Down
2 changes: 1 addition & 1 deletion fb/util/Output.as
Expand Up @@ -24,7 +24,7 @@ package fb.util {
import fb.util.FlexUtil;

public class Output {
private static var verbose:Boolean = false;
private static var verbose:Boolean = true;
private static var debugFile:File = FlexUtil.getUserPath("air_debug.txt");
private static var debugStream:FileStream = new FileStream();
private static var loggedItems:Array = new Array();
Expand Down
2 changes: 1 addition & 1 deletion fbair.mxml
Expand Up @@ -144,7 +144,7 @@
// Now we call this to init our application.
// Always call this only once, in the applicationComplete callback.
FBConnect.init('39f0aec9479177cddacef90da714b037');
FBConnect.init('4b38d3e1a6df930669e13b82e3ba8974');//39f0aec9479177cddacef90da714b037');
// This function checks to see if we're already connected
statusChanged();
Expand Down
4 changes: 2 additions & 2 deletions fbair/nile/NileContainer.mxml
Expand Up @@ -64,7 +64,7 @@
import mx.events.ScrollEvent;
import mx.utils.ObjectUtil;
private static const PollingDelay:int = 30000;
private static const PollingDelay:int = 10000;
private static const MinAnimationDelay:int = 500;
private static const PageScrollSize:int = 512;
private static const MouseWheelSize:int = 16;
Expand Down Expand Up @@ -318,7 +318,7 @@
// Get latestUpdates on these jonx filters
for (var filterKey:String in dataCache) {
var filterList:ArrayCollection = dataCache[filterKey];
latestUpdates[filterKey] = filterList.length > 0 ?
latestUpdates[filterKey] = filterList.length == MaxEntries ?
filterList[filterList.length-1].created_time : 0;
}
}
Expand Down
1 change: 1 addition & 0 deletions fbair/util/CommentCache.as
Expand Up @@ -16,6 +16,7 @@
package fbair.util {
import fb.FBAPI;
import fb.FBEvent;

import flash.events.Event;
import flash.events.EventDispatcher;

Expand Down

0 comments on commit e79312a

Please sign in to comment.