mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1008901 - Fire 'onlogin' when the account is verified. r=jedp
This commit is contained in:
parent
9aee0d4240
commit
9e06d7e779
@ -758,9 +758,9 @@ FxAccountsInternal.prototype = {
|
||||
);
|
||||
},
|
||||
|
||||
notifyObservers: function(topic) {
|
||||
notifyObservers: function(topic, data) {
|
||||
log.debug("Notifying observers of " + topic);
|
||||
Services.obs.notifyObservers(null, topic, null);
|
||||
Services.obs.notifyObservers(null, topic, data);
|
||||
},
|
||||
|
||||
// XXX - pollEmailStatus should maybe be on the AccountState object?
|
||||
@ -800,6 +800,8 @@ FxAccountsInternal.prototype = {
|
||||
currentState.whenVerifiedDeferred.resolve(data);
|
||||
delete currentState.whenVerifiedDeferred;
|
||||
}
|
||||
// Tell FxAccountsManager to clear its cache
|
||||
this.notifyObservers(ON_FXA_UPDATE_NOTIFICATION, ONVERIFIED_NOTIFICATION);
|
||||
});
|
||||
} else {
|
||||
log.debug("polling with step = " + this.POLL_STEP);
|
||||
|
@ -83,6 +83,8 @@ this.POLL_STEP = 1000 * 3; // 3 seconds
|
||||
this.ONLOGIN_NOTIFICATION = "fxaccounts:onlogin";
|
||||
this.ONVERIFIED_NOTIFICATION = "fxaccounts:onverified";
|
||||
this.ONLOGOUT_NOTIFICATION = "fxaccounts:onlogout";
|
||||
// Internal to services/fxaccounts only
|
||||
this.ON_FXA_UPDATE_NOTIFICATION = "fxaccounts:update";
|
||||
|
||||
// UI Requests.
|
||||
this.UI_REQUEST_SIGN_IN_FLOW = "signInFlow";
|
||||
|
@ -25,15 +25,17 @@ this.FxAccountsManager = {
|
||||
|
||||
init: function() {
|
||||
Services.obs.addObserver(this, ONLOGOUT_NOTIFICATION, false);
|
||||
Services.obs.addObserver(this, ON_FXA_UPDATE_NOTIFICATION, false);
|
||||
},
|
||||
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic !== ONLOGOUT_NOTIFICATION) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove the cached session if we get a logout notification.
|
||||
// Both topics indicate our cache is invalid
|
||||
this._activeSession = null;
|
||||
|
||||
if (aData == ONVERIFIED_NOTIFICATION) {
|
||||
log.debug("FxAccountsManager: cache cleared, broadcasting: " + aData);
|
||||
Services.obs.notifyObservers(null, aData, null);
|
||||
}
|
||||
},
|
||||
|
||||
// We don't really need to save fxAccounts instance but this way we allow
|
||||
|
@ -39,13 +39,18 @@ log.addAppender(new Log.ConsoleAppender(new Log.BasicFormatter()));
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "FxAccountsManager",
|
||||
"resource://gre/modules/FxAccountsManager.jsm",
|
||||
"FxAccountsManager");
|
||||
Cu.import("resource://gre/modules/FxAccountsCommon.js");
|
||||
#else
|
||||
log.warn("The FxAccountsManager is only functional in B2G at this time.");
|
||||
var FxAccountsManager = null;
|
||||
var ONVERIFIED_NOTIFICATION = null;
|
||||
#endif
|
||||
|
||||
function FxAccountsService() {
|
||||
Services.obs.addObserver(this, "quit-application-granted", false);
|
||||
if (ONVERIFIED_NOTIFICATION) {
|
||||
Services.obs.addObserver(this, ONVERIFIED_NOTIFICATION, false);
|
||||
}
|
||||
|
||||
// Maintain interface parity with Identity.jsm and MinimalIdentity.jsm
|
||||
this.RP = this;
|
||||
@ -61,8 +66,20 @@ FxAccountsService.prototype = {
|
||||
|
||||
observe: function observe(aSubject, aTopic, aData) {
|
||||
switch (aTopic) {
|
||||
case null:
|
||||
// Paranoia against matching null ONVERIFIED_NOTIFICATION
|
||||
break;
|
||||
case ONVERIFIED_NOTIFICATION:
|
||||
log.debug("Received " + ONVERIFIED_NOTIFICATION + "; firing request()s");
|
||||
for (let [rpId,] of this._rpFlows) {
|
||||
this.request(rpId);
|
||||
}
|
||||
break;
|
||||
case "quit-application-granted":
|
||||
Services.obs.removeObserver(this, "quit-application-granted");
|
||||
if (ONVERIFIED_NOTIFICATION) {
|
||||
Services.obs.removeObserver(this, ONVERIFIED_NOTIFICATION);
|
||||
}
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user