Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Issue #51 , improved permission level behaviour

  • Loading branch information...
commit 3422eb29ad1b7ed90913cfca4b61158dcbce0137 1 parent 3b69eae
@mackers mackers authored
Showing with 12 additions and 2 deletions.
  1. +2 −1  chrome/content/lib.js
  2. +10 −1 components/facebook.js
View
3  chrome/content/lib.js
@@ -750,12 +750,13 @@ var fbLib = {
var prefSvc = Cc['@mozilla.org/preferences-service;1'].getService(Ci.nsIPrefBranch);
var accessToken = prefSvc.getCharPref('extensions.facebook.access_token');
var permissionsLevel = prefSvc.getIntPref('extensions.facebook.permissions.level');
- if (accessToken || permissionsLevel >= 1) {
+ if (accessToken || permissionsLevel > 0) {
fbLib.openAndReuseOneTabPerURL("https://www.facebook.com/login.php");
fbLib.setAttributeById('facebook-login-status', 'status', 'waiting');
setTimeout(function() { fbLib.setAttributeById('facebook-login-status', 'status', ''); }, 60*1000);
}
else {
+ prefSvc.setIntPref('extensions.facebook.permissions.level', 0);
var askUrl = "https://www.facebook.com/dialog/oauth?client_id=" + fbSvc.wrappedJSObject._appId + "&redirect_uri=http://www.facebook.com/&scope=manage_notifications,user_photos,publish_stream,status_update,friends_status&response_type=token";
gBrowser.selectedTab = gBrowser.addTab(askUrl);
}
View
11 components/facebook.js
@@ -64,6 +64,7 @@ const PASSWORD_URL = 'chrome://facebook/';
const TOPIC_SESSION_START= "facebook-session-start-oauth";
const TOPIC_SESSION_END= "facebook-session-end";
+const PERMISSIONS_LEVEL= 2;
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
@@ -546,7 +547,6 @@ facebookService.prototype = {
fbSvc._loggedIn = true;
fbSvc._prefService.setCharPref('extensions.facebook.access_token', accessToken);
fbSvc._prefService.setCharPref('extensions.facebook.uid', fbSvc._uid);
- fbSvc._prefService.setIntPref('extensions.facebook.permissions.level', 1);
}
else
{
@@ -555,6 +555,15 @@ facebookService.prototype = {
return;
}
+ if (fbSvc._prefService.getIntPref('extensions.facebook.permissions.level') > 0
+ && fbSvc._prefService.getIntPref('extensions.facebook.permissions.level') < PERMISSIONS_LEVEL)
+ {
+ debug("need a permissions upgrade");
+ fbSvc.sessionEnd();
+ return;
+ }
+ fbSvc._prefService.setIntPref('extensions.facebook.permissions.level', PERMISSIONS_LEVEL);
+
Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService)
.notifyObservers(null, TOPIC_SESSION_START, response.id);
Please sign in to comment.
Something went wrong with that request. Please try again.