mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 806605 - Replace loggedInEmail parameter with loggedInUser. r=benadida
This commit is contained in:
parent
78d5b9d481
commit
4886a2138b
@ -143,7 +143,7 @@ let Pipe = {
|
|||||||
* provide a callback for handling messages.
|
* provide a callback for handling messages.
|
||||||
*
|
*
|
||||||
* @param aRpOptions options describing the Relying Party's
|
* @param aRpOptions options describing the Relying Party's
|
||||||
* (dicitonary) call, such as origin and loggedInEmail.
|
* (dictionary) call, such as origin and loggedInUser.
|
||||||
*
|
*
|
||||||
* @param aGaiaOptions showUI: boolean
|
* @param aGaiaOptions showUI: boolean
|
||||||
* (dictionary) message: name of the message to emit
|
* (dictionary) message: name of the message to emit
|
||||||
|
@ -50,7 +50,7 @@ function uuid() {
|
|||||||
function mockDoc(aIdentity, aOrigin, aDoFunc) {
|
function mockDoc(aIdentity, aOrigin, aDoFunc) {
|
||||||
let mockedDoc = {};
|
let mockedDoc = {};
|
||||||
mockedDoc.id = uuid();
|
mockedDoc.id = uuid();
|
||||||
mockedDoc.loggedInEmail = aIdentity;
|
mockedDoc.loggedInUser = aIdentity;
|
||||||
mockedDoc.origin = aOrigin;
|
mockedDoc.origin = aOrigin;
|
||||||
mockedDoc['do'] = aDoFunc;
|
mockedDoc['do'] = aDoFunc;
|
||||||
mockedDoc.doReady = partial(aDoFunc, 'ready');
|
mockedDoc.doReady = partial(aDoFunc, 'ready');
|
||||||
|
@ -87,17 +87,17 @@ IDPAuthenticationContext.prototype = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
function RPWatchContext(aID, aOrigin, aLoggedInEmail, aTargetMM) {
|
function RPWatchContext(aID, aOrigin, aLoggedInUser, aTargetMM) {
|
||||||
this._id = aID;
|
this._id = aID;
|
||||||
this._origin = aOrigin;
|
this._origin = aOrigin;
|
||||||
this._loggedInEmail = aLoggedInEmail;
|
this._loggedInUser = aLoggedInUser;
|
||||||
this._mm = aTargetMM;
|
this._mm = aTargetMM;
|
||||||
}
|
}
|
||||||
|
|
||||||
RPWatchContext.prototype = {
|
RPWatchContext.prototype = {
|
||||||
get id() this._id,
|
get id() this._id,
|
||||||
get origin() this._origin,
|
get origin() this._origin,
|
||||||
get loggedInEmail() this._loggedInEmail,
|
get loggedInUser() this._loggedInUser,
|
||||||
|
|
||||||
doLogin: function RPWatchContext_onlogin(aAssertion) {
|
doLogin: function RPWatchContext_onlogin(aAssertion) {
|
||||||
log("doLogin: " + this.id);
|
log("doLogin: " + this.id);
|
||||||
@ -221,7 +221,7 @@ this.DOMIdentity = {
|
|||||||
// Pass an object with the watch members to Identity.jsm so it can call the
|
// Pass an object with the watch members to Identity.jsm so it can call the
|
||||||
// callbacks.
|
// callbacks.
|
||||||
let context = new RPWatchContext(message.id, message.origin,
|
let context = new RPWatchContext(message.id, message.origin,
|
||||||
message.loggedInEmail, targetMM);
|
message.loggedInUser, targetMM);
|
||||||
IdentityService.RP.watch(context);
|
IdentityService.RP.watch(context);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ const MAX_RP_CALLS = 100;
|
|||||||
|
|
||||||
Cu.import("resource://gre/modules/Services.jsm");
|
Cu.import("resource://gre/modules/Services.jsm");
|
||||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
|
Cu.import("resource://gre/modules/IdentityUtils.jsm");
|
||||||
|
|
||||||
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
|
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
|
||||||
"@mozilla.org/childprocessmessagemanager;1",
|
"@mozilla.org/childprocessmessagemanager;1",
|
||||||
@ -78,24 +79,30 @@ nsDOMIdentity.prototype = {
|
|||||||
|
|
||||||
let message = this.DOMIdentityMessage();
|
let message = this.DOMIdentityMessage();
|
||||||
|
|
||||||
// loggedInEmail
|
// loggedInUser vs loggedInEmail
|
||||||
message.loggedInEmail = null;
|
// https://developer.mozilla.org/en-US/docs/DOM/navigator.id.watch
|
||||||
let emailType = typeof(aOptions["loggedInEmail"]);
|
// This parameter, loggedInUser, was renamed from loggedInEmail in early
|
||||||
if (aOptions["loggedInEmail"] && aOptions["loggedInEmail"] !== "undefined") {
|
// September, 2012. Both names will continue to work for the time being,
|
||||||
|
// but code should be changed to use loggedInUser instead.
|
||||||
|
checkRenamed(aOptions, "loggedInEmail", "loggedInUser");
|
||||||
|
message["loggedInUser"] = aOptions["loggedInUser"];
|
||||||
|
|
||||||
|
let emailType = typeof(aOptions["loggedInUser"]);
|
||||||
|
if (aOptions["loggedInUser"] && aOptions["loggedInUser"] !== "undefined") {
|
||||||
if (emailType !== "string") {
|
if (emailType !== "string") {
|
||||||
throw new Error("loggedInEmail must be a String or null");
|
throw new Error("loggedInUser must be a String or null");
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Bug 767610 - check email format.
|
// TODO: Bug 767610 - check email format.
|
||||||
// See nsHTMLInputElement::IsValidEmailAddress
|
// See nsHTMLInputElement::IsValidEmailAddress
|
||||||
if (aOptions["loggedInEmail"].indexOf("@") == -1
|
if (aOptions["loggedInUser"].indexOf("@") == -1
|
||||||
|| aOptions["loggedInEmail"].length > MAX_STRING_LENGTH) {
|
|| aOptions["loggedInUser"].length > MAX_STRING_LENGTH) {
|
||||||
throw new Error("loggedInEmail is not valid");
|
throw new Error("loggedInUser is not valid");
|
||||||
}
|
}
|
||||||
// Set loggedInEmail in this block that "undefined" doesn't get through.
|
// Set loggedInUser in this block that "undefined" doesn't get through.
|
||||||
message.loggedInEmail = aOptions.loggedInEmail;
|
message.loggedInUser = aOptions.loggedInUser;
|
||||||
}
|
}
|
||||||
this._log("loggedInEmail: " + message.loggedInEmail);
|
this._log("loggedInUser: " + message.loggedInUser);
|
||||||
|
|
||||||
this._rpWatcher = aOptions;
|
this._rpWatcher = aOptions;
|
||||||
this._identityInternal._mm.sendAsyncMessage("Identity:RP:Watch", message);
|
this._identityInternal._mm.sendAsyncMessage("Identity:RP:Watch", message);
|
||||||
|
@ -131,7 +131,7 @@ IDService.prototype = {
|
|||||||
let provId = rp.provId;
|
let provId = rp.provId;
|
||||||
|
|
||||||
let rpLoginOptions = {
|
let rpLoginOptions = {
|
||||||
loggedInEmail: aIdentity,
|
loggedInUser: aIdentity,
|
||||||
origin: rp.origin
|
origin: rp.origin
|
||||||
};
|
};
|
||||||
log("selectIdentity: provId:", provId, "origin:", rp.origin);
|
log("selectIdentity: provId:", provId, "origin:", rp.origin);
|
||||||
|
46
toolkit/identity/IdentityUtils.jsm
Normal file
46
toolkit/identity/IdentityUtils.jsm
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/* -*- Mode: js2; js2-basic-offset: 2; indent-tabs-mode: nil; -*- */
|
||||||
|
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
// functions common to Identity.jsm and MinimalIdentity.jsm
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const EXPORTED_SYMBOLS = ["checkRenamed"];
|
||||||
|
const Cu = Components.utils;
|
||||||
|
|
||||||
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
|
XPCOMUtils.defineLazyModuleGetter(this, "Logger",
|
||||||
|
"resource://gre/modules/identity/LogUtils.jsm");
|
||||||
|
|
||||||
|
function log(...aMessageArgs) {
|
||||||
|
Logger.log.apply(Logger, ["Identity"].concat(aMessageArgs));
|
||||||
|
}
|
||||||
|
|
||||||
|
function defined(item) {
|
||||||
|
return typeof item !== 'undefined';
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkDeprecated(aOptions, aField) {
|
||||||
|
if (defined(aOptions[aField])) {
|
||||||
|
log("WARNING: field is deprecated:", aField);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
let checkRenamed = function checkRenamed(aOptions, aOldName, aNewName) {
|
||||||
|
if (defined(aOptions[aOldName]) &&
|
||||||
|
defined(aOptions[aNewName])) {
|
||||||
|
let err = "You cannot provide both " + aOldName + " and " + aNewName;
|
||||||
|
Logger.reportError(err);
|
||||||
|
throw new Error(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (checkDeprecated(aOptions, aOldName)) {
|
||||||
|
aOptions[aNewName] = aOptions[aOldName];
|
||||||
|
delete(aOptions[aOldName]);
|
||||||
|
}
|
||||||
|
};
|
@ -30,6 +30,7 @@ CPPSRCS = \
|
|||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
EXTRA_JS_MODULES = \
|
EXTRA_JS_MODULES = \
|
||||||
|
IdentityUtils.jsm \
|
||||||
Identity.jsm \
|
Identity.jsm \
|
||||||
IdentityProvider.jsm \
|
IdentityProvider.jsm \
|
||||||
IdentityStore.jsm \
|
IdentityStore.jsm \
|
||||||
|
@ -85,7 +85,7 @@ IDService.prototype = {
|
|||||||
* (Object) an object that represents the caller document, and
|
* (Object) an object that represents the caller document, and
|
||||||
* is expected to have properties:
|
* is expected to have properties:
|
||||||
* - id (unique, e.g. uuid)
|
* - id (unique, e.g. uuid)
|
||||||
* - loggedInEmail (string or null)
|
* - loggedInUser (string or null)
|
||||||
* - origin (string)
|
* - origin (string)
|
||||||
*
|
*
|
||||||
* and a bunch of callbacks
|
* and a bunch of callbacks
|
||||||
@ -101,12 +101,11 @@ IDService.prototype = {
|
|||||||
log("watch: rpcaller:", aRpCaller);
|
log("watch: rpcaller:", aRpCaller);
|
||||||
// store the caller structure and notify the UI observers
|
// store the caller structure and notify the UI observers
|
||||||
|
|
||||||
// note that, unfortunately, what here is loggedInEmail is called
|
|
||||||
// loggedInUser in the native API.
|
|
||||||
this._rpFlows[aRpCaller.id] = aRpCaller;
|
this._rpFlows[aRpCaller.id] = aRpCaller;
|
||||||
|
|
||||||
let options = {rpId: aRpCaller.id,
|
let options = {rpId: aRpCaller.id,
|
||||||
origin: aRpCaller.origin,
|
origin: aRpCaller.origin,
|
||||||
loggedInUser: aRpCaller.loggedInEmail || null};
|
loggedInUser: aRpCaller.loggedInUser};
|
||||||
log("sending identity-controller-watch:", options);
|
log("sending identity-controller-watch:", options);
|
||||||
Services.obs.notifyObservers({wrappedJSObject: options},"identity-controller-watch", null);
|
Services.obs.notifyObservers({wrappedJSObject: options},"identity-controller-watch", null);
|
||||||
},
|
},
|
||||||
|
@ -70,7 +70,7 @@ IdentityRelyingParty.prototype = {
|
|||||||
* (Object) an object that represents the caller document, and
|
* (Object) an object that represents the caller document, and
|
||||||
* is expected to have properties:
|
* is expected to have properties:
|
||||||
* - id (unique, e.g. uuid)
|
* - id (unique, e.g. uuid)
|
||||||
* - loggedInEmail (string or null)
|
* - loggedInUser (string or null)
|
||||||
* - origin (string)
|
* - origin (string)
|
||||||
*
|
*
|
||||||
* and a bunch of callbacks
|
* and a bunch of callbacks
|
||||||
@ -88,7 +88,7 @@ IdentityRelyingParty.prototype = {
|
|||||||
|
|
||||||
log("watch: rpId:", aRpCaller.id,
|
log("watch: rpId:", aRpCaller.id,
|
||||||
"origin:", origin,
|
"origin:", origin,
|
||||||
"loggedInEmail:", aRpCaller.loggedInEmail,
|
"loggedInUser:", aRpCaller.loggedInUser,
|
||||||
"loggedIn:", state.isLoggedIn,
|
"loggedIn:", state.isLoggedIn,
|
||||||
"email:", state.email);
|
"email:", state.email);
|
||||||
|
|
||||||
@ -99,20 +99,20 @@ IdentityRelyingParty.prototype = {
|
|||||||
// 2. the email is null: 'login'; 'ready'
|
// 2. the email is null: 'login'; 'ready'
|
||||||
// 3. the email has changed: 'login'; 'ready'
|
// 3. the email has changed: 'login'; 'ready'
|
||||||
if (state.isLoggedIn) {
|
if (state.isLoggedIn) {
|
||||||
if (state.email && aRpCaller.loggedInEmail === state.email) {
|
if (state.email && aRpCaller.loggedInUser === state.email) {
|
||||||
this._notifyLoginStateChanged(aRpCaller.id, state.email);
|
this._notifyLoginStateChanged(aRpCaller.id, state.email);
|
||||||
return aRpCaller.doReady();
|
return aRpCaller.doReady();
|
||||||
|
|
||||||
} else if (aRpCaller.loggedInEmail === null) {
|
} else if (aRpCaller.loggedInUser === null) {
|
||||||
// Generate assertion for existing login
|
// Generate assertion for existing login
|
||||||
let options = {loggedInEmail: state.email, origin: origin};
|
let options = {loggedInUser: state.email, origin: origin};
|
||||||
return this._doLogin(aRpCaller, options);
|
return this._doLogin(aRpCaller, options);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// A loggedInEmail different from state.email has been specified.
|
// A loggedInUser different from state.email has been specified.
|
||||||
// Change login identity.
|
// Change login identity.
|
||||||
|
|
||||||
let options = {loggedInEmail: state.email, origin: origin};
|
let options = {loggedInUser: state.email, origin: origin};
|
||||||
return this._doLogin(aRpCaller, options);
|
return this._doLogin(aRpCaller, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ IdentityRelyingParty.prototype = {
|
|||||||
// 2. not logged in, no email given: 'ready';
|
// 2. not logged in, no email given: 'ready';
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (aRpCaller.loggedInEmail) {
|
if (aRpCaller.loggedInUser) {
|
||||||
return this._doLogout(aRpCaller, {origin: origin});
|
return this._doLogout(aRpCaller, {origin: origin});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -141,8 +141,8 @@ IdentityRelyingParty.prototype = {
|
|||||||
log("_doLogin: rpId:", aRpCaller.id, "origin:", aOptions.origin);
|
log("_doLogin: rpId:", aRpCaller.id, "origin:", aOptions.origin);
|
||||||
|
|
||||||
let loginWithAssertion = function loginWithAssertion(assertion) {
|
let loginWithAssertion = function loginWithAssertion(assertion) {
|
||||||
this._store.setLoginState(aOptions.origin, true, aOptions.loggedInEmail);
|
this._store.setLoginState(aOptions.origin, true, aOptions.loggedInUser);
|
||||||
this._notifyLoginStateChanged(aRpCaller.id, aOptions.loggedInEmail);
|
this._notifyLoginStateChanged(aRpCaller.id, aOptions.loggedInUser);
|
||||||
aRpCaller.doLogin(assertion);
|
aRpCaller.doLogin(assertion);
|
||||||
aRpCaller.doReady();
|
aRpCaller.doReady();
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
@ -290,7 +290,7 @@ IdentityRelyingParty.prototype = {
|
|||||||
*/
|
*/
|
||||||
_getAssertion: function _getAssertion(aOptions, aCallback) {
|
_getAssertion: function _getAssertion(aOptions, aCallback) {
|
||||||
let audience = aOptions.origin;
|
let audience = aOptions.origin;
|
||||||
let email = aOptions.loggedInEmail || this.getDefaultEmailForOrigin(audience);
|
let email = aOptions.loggedInUser || this.getDefaultEmailForOrigin(audience);
|
||||||
log("_getAssertion: audience:", audience, "email:", email);
|
log("_getAssertion: audience:", audience, "email:", email);
|
||||||
if (!audience) {
|
if (!audience) {
|
||||||
throw "audience required for _getAssertion";
|
throw "audience required for _getAssertion";
|
||||||
|
@ -100,7 +100,7 @@ function uuid() {
|
|||||||
function mock_doc(aIdentity, aOrigin, aDoFunc) {
|
function mock_doc(aIdentity, aOrigin, aDoFunc) {
|
||||||
let mockedDoc = {};
|
let mockedDoc = {};
|
||||||
mockedDoc.id = uuid();
|
mockedDoc.id = uuid();
|
||||||
mockedDoc.loggedInEmail = aIdentity;
|
mockedDoc.loggedInUser = aIdentity;
|
||||||
mockedDoc.origin = aOrigin;
|
mockedDoc.origin = aOrigin;
|
||||||
mockedDoc['do'] = aDoFunc;
|
mockedDoc['do'] = aDoFunc;
|
||||||
mockedDoc.doReady = partial(aDoFunc, 'ready');
|
mockedDoc.doReady = partial(aDoFunc, 'ready');
|
||||||
|
Loading…
Reference in New Issue
Block a user