Bug 1162495 - When using FxAccountsOAuthClient, unable to specify email parameter to go with action="force_auth". r=MattN

This commit is contained in:
Mark Banner 2015-05-08 13:46:52 +01:00
parent 73d7ecd942
commit aaa5a96002
2 changed files with 20 additions and 2 deletions

View File

@ -36,7 +36,9 @@ Cu.importGlobalProperties(["URL"]);
* @param {String} [options.parameters.scope]
* Optional. A colon-separated list of scopes that the user has authorized
* @param {String} [options.parameters.action]
* Optional. If provided, should be either signup or signin.
* Optional. If provided, should be either signup, signin or force_auth.
* @param {String} [options.parameters.email]
* Optional. Required if options.paramters.action is 'force_auth'.
* @param {Boolean} [options.parameters.keys]
* Optional. If true then relier-specific encryption keys will be
* available in the second argument to onComplete.
@ -66,7 +68,10 @@ this.FxAccountsOAuthClient = function(options) {
if (this.parameters.keys) {
params.append("keys", "true");
}
// Only append if we actually have a value.
if (this.parameters.email) {
params.append("email", this.parameters.email);
}
};
this.FxAccountsOAuthClient.prototype = {
@ -256,5 +261,9 @@ this.FxAccountsOAuthClient.prototype = {
throw new Error("Missing 'parameters." + option + "' parameter");
}
});
if (options.parameters.action == "force_auth" && !options.parameters.email) {
throw new Error("parameters.email is required for action 'force_auth'");
}
},
};

View File

@ -33,6 +33,15 @@ function run_test() {
}},
"Error: Missing 'parameters.state' parameter");
validationHelper({ parameters: {
oauth_uri: "http://oauth.test/v1",
client_id: "client_id",
content_uri: "http://content.test",
state: "complete",
action: "force_auth"
}},
"Error: parameters.email is required for action 'force_auth'");
run_next_test();
}