Remove Accounts.{facebook,github,google}.config. Replace with options in loginWithFacebook.

This commit is contained in:
Nick Martin
2012-10-09 01:56:10 -07:00
committed by Avital Oliver
parent 14f975ea30
commit accd41bddf
6 changed files with 29 additions and 28 deletions

View File

@@ -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 +

View File

@@ -1,7 +1,3 @@
if (!Accounts.facebook) {
Accounts.facebook = {};
}
Accounts.facebook.config = function(options) {
Accounts.facebook._options = options;
};

View File

@@ -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 =

View File

@@ -1,7 +1,3 @@
if (!Accounts.github) {
Accounts.github = {};
}
Accounts.github.config = function(options) {
Accounts.github._options = options;
};

View File

@@ -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('+');

View File

@@ -1,7 +1,3 @@
if (!Accounts.google) {
Accounts.google = {};
}
Accounts.google.config = function(options) {
Accounts.google._options = options;
};