diff --git a/packages/accounts-facebook/facebook_client.js b/packages/accounts-facebook/facebook_client.js index 462e373bab..2b780c39ce 100644 --- a/packages/accounts-facebook/facebook_client.js +++ b/packages/accounts-facebook/facebook_client.js @@ -1,6 +1,12 @@ (function () { - Meteor.loginWithFacebook = function (callback) { - var config = Accounts.loginServiceConfiguration.findOne({service: 'facebook'}); + Meteor.loginWithFacebook = function (options, callback) { + // support both (options, callback) and (callback). + if (!callback && typeof options === 'function') { + callback = options; + options = {}; + } + + var config = Accounts.configuration.findOne({service: 'facebook'}); if (!config) { callback && callback(new Accounts.ConfigError("Service not configured")); return; @@ -11,9 +17,8 @@ var display = mobile ? 'touch' : 'popup'; var scope = "email"; - if (Accounts.facebook._options && - Accounts.facebook._options.scope) - scope = Accounts.facebook._options.scope.join(','); + if (options && options.scope) + scope = options.scope.join(','); var loginUrl = 'https://www.facebook.com/dialog/oauth?client_id=' + config.appId + diff --git a/packages/accounts-facebook/facebook_common.js b/packages/accounts-facebook/facebook_common.js index d04176578e..171ca036f6 100644 --- a/packages/accounts-facebook/facebook_common.js +++ b/packages/accounts-facebook/facebook_common.js @@ -1,7 +1,3 @@ if (!Accounts.facebook) { Accounts.facebook = {}; } - -Accounts.facebook.config = function(options) { - Accounts.facebook._options = options; -}; diff --git a/packages/accounts-github/github_client.js b/packages/accounts-github/github_client.js index 5fa06d1ba1..967cc25df4 100644 --- a/packages/accounts-github/github_client.js +++ b/packages/accounts-github/github_client.js @@ -1,6 +1,12 @@ (function () { - Meteor.loginWithGithub = function (callback) { - var config = Accounts.loginServiceConfiguration.findOne({service: 'github'}); + Meteor.loginWithGithub = function (options, callback) { + // support both (options, callback) and (callback). + if (!callback && typeof options === 'function') { + callback = options; + options = {}; + } + + var config = Accounts.configuration.findOne({service: 'github'}); if (!config) { callback && callback(new Accounts.ConfigError("Service not configured")); return; @@ -8,10 +14,7 @@ var state = Meteor.uuid(); var required_scope = ['user']; - var scope = []; - if (Accounts.github._options && Accounts.github._options.scope) - scope = Accounts.github._options.scope; - scope = _.union(scope, required_scope); + var scope = _.union((options && options.scope) || [], required_scope); var flat_scope = _.map(scope, encodeURIComponent).join('+'); var loginUrl = diff --git a/packages/accounts-github/github_common.js b/packages/accounts-github/github_common.js index cbf1544260..0e9b508596 100644 --- a/packages/accounts-github/github_common.js +++ b/packages/accounts-github/github_common.js @@ -1,7 +1,3 @@ if (!Accounts.github) { Accounts.github = {}; } - -Accounts.github.config = function(options) { - Accounts.github._options = options; -}; \ No newline at end of file diff --git a/packages/accounts-google/google_client.js b/packages/accounts-google/google_client.js index c998f69934..a0cb59fe06 100644 --- a/packages/accounts-google/google_client.js +++ b/packages/accounts-google/google_client.js @@ -1,6 +1,12 @@ (function () { - Meteor.loginWithGoogle = function (callback) { - var config = Accounts.loginServiceConfiguration.findOne({service: 'google'}); + Meteor.loginWithGoogle = function (options, callback) { + // support both (options, callback) and (callback). + if (!callback && typeof options === 'function') { + callback = options; + options = {}; + } + + var config = Accounts.configuration.findOne({service: 'google'}); if (!config) { callback && callback(new Accounts.ConfigError("Service not configured")); return; @@ -11,9 +17,8 @@ // always need this to get user id from google. var required_scope = ['https://www.googleapis.com/auth/userinfo.profile']; var scope = ['https://www.googleapis.com/auth/userinfo.email']; - if (Accounts.google._options && - Accounts.google._options.scope) - scope = Accounts.google._options.scope; + if (options && options.scope) + scope = options.scope; scope = _.union(scope, required_scope); var flat_scope = _.map(scope, encodeURIComponent).join('+'); diff --git a/packages/accounts-google/google_common.js b/packages/accounts-google/google_common.js index 8ca64f59f9..f3945c2c23 100644 --- a/packages/accounts-google/google_common.js +++ b/packages/accounts-google/google_common.js @@ -1,7 +1,3 @@ if (!Accounts.google) { Accounts.google = {}; } - -Accounts.google.config = function(options) { - Accounts.google._options = options; -};