Merge branch 'pr/2183' into devel

This commit is contained in:
Emily Stark
2014-06-10 15:17:24 -07:00
3 changed files with 19 additions and 4 deletions

View File

@@ -1125,6 +1125,11 @@ Template.api.loginWithExternalService = {
name: "forceApprovalPrompt",
type: "Boolean",
descr: "If true, forces the user to approve the app's permissions, even if previously approved. Currently only supported with Google."
},
{
name: "userEmail",
type: "String",
descr: "An email address that the external service will use to pre-fill the login prompt. Currently only supported with Meteor developer accounts."
}
]
};

View File

@@ -10,7 +10,7 @@ if (Meteor.isClient) {
var credentialRequestCompleteCallback =
Accounts.oauth.credentialRequestCompleteHandler(callback);
MeteorDeveloperAccounts.requestCredential(credentialRequestCompleteCallback);
MeteorDeveloperAccounts.requestCredential(options, credentialRequestCompleteCallback);
};
} else {
Accounts.addAutopublishFields({

View File

@@ -4,7 +4,13 @@ MeteorDeveloperAccounts = {};
// @param credentialRequestCompleteCallback {Function} Callback function to call on
// completion. Takes one argument, credentialToken on success, or Error on
// error.
var requestCredential = function (credentialRequestCompleteCallback) {
var requestCredential = function (options, credentialRequestCompleteCallback) {
// support a callback without options
if (! credentialRequestCompleteCallback && typeof options === "function") {
credentialRequestCompleteCallback = options;
options = null;
}
var config = ServiceConfiguration.configurations.findOne({
service: 'meteor-developer'
});
@@ -20,8 +26,12 @@ var requestCredential = function (credentialRequestCompleteCallback) {
METEOR_DEVELOPER_URL + "/oauth2/authorize?" +
"state=" + credentialToken +
"&response_type=code&" +
"client_id=" + config.clientId +
"&redirect_uri=" + Meteor.absoluteUrl("_oauth/meteor-developer?close");
"client_id=" + config.clientId;
if (options && options.userEmail)
loginUrl += '&user_email=' + encodeURIComponent(options.userEmail);
loginUrl += "&redirect_uri=" + Meteor.absoluteUrl("_oauth/meteor-developer?close");
OAuth.showPopup(
loginUrl,