Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Fix #1704, check for the user auth cookie when checking if the browse…
Browse files Browse the repository at this point in the history
…r is logged in.
  • Loading branch information
ianb committed Oct 5, 2016
1 parent dc10023 commit 9b192cf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 9 additions & 1 deletion addon/lib/get-cookies.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const { Ci } = require("chrome");
const { Ci, Cc } = require("chrome");
const { Services } = require("resource://gre/modules/Services.jsm");
const { URL } = require("sdk/url");
const cookieService = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsICookieService);
const { newURI } = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);

function getCookieObjects(host) {
let result = [];
Expand Down Expand Up @@ -50,3 +52,9 @@ exports.safeCookieSummary = function (host) {
return `Could not capture cookies for ${host}: ${e}`;
}
};

exports.hasCookieForBackend = function (backend) {
let backendUrl = newURI(backend, null, null);
let cookieString = cookieService.getCookieStringFromHttp(backendUrl, backendUrl, null);
return cookieString.search(/user=/) != -1;
};
3 changes: 2 additions & 1 deletion addon/lib/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const { URL } = require('sdk/url');
const { FxAccountsOAuthClient } = Cu.import("resource://gre/modules/FxAccountsOAuthClient.jsm", {});
const { FxAccountsProfileClient } = Cu.import("resource://gre/modules/FxAccountsProfileClient.jsm", {});
const { deviceInfo } = require('./deviceinfo');
const { hasCookieForBackend } = require("./get-cookies");

let initialized = false;
let sentryPublicDSN = "";
Expand Down Expand Up @@ -44,7 +45,7 @@ exports.deleteEverything = function () {
};

exports.isInitialized = function () {
return initialized;
return initialized && hasCookieForBackend(require("./main").getBackend());
};

let cachedBackend, cachedReason; // eslint-disable-line no-unused-vars
Expand Down

0 comments on commit 9b192cf

Please sign in to comment.