From 25a3dfc292c9a164170fce44d94908bd6413b67f Mon Sep 17 00:00:00 2001 From: Tom Coleman Date: Fri, 16 Aug 2013 10:49:50 +1000 Subject: [PATCH] Works with 0.6.5 --- .gitignore | 1 + login_buttons.js | 34 +++++++--------------------------- package.js | 13 ++++++++++++- 3 files changed, 20 insertions(+), 28 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..677a6fc --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.build* diff --git a/login_buttons.js b/login_buttons.js index 1c89017..347141a 100644 --- a/login_buttons.js +++ b/login_buttons.js @@ -112,38 +112,18 @@ Accounts._loginButtons.displayName = function () { // login_buttons_dropdown.html Accounts._loginButtons.getLoginServices = function () { var self = this; - var services = []; - - // find all methods of the form: `Meteor.loginWithFoo`, where - // `Foo` corresponds to a login service - // - // XXX we should consider having a client-side - // Accounts.oauth.registerService function which records the - // active services and encapsulates boilerplate code now found in - // files such as facebook_client.js. This would have the added - // benefit of allow us to unify facebook_{client,common,server}.js - // into one file, which would encourage people to build more login - // services packages. - _.each(_.keys(Meteor), function(methodName) { - var match; - if ((match = methodName.match(/^loginWith(.*)/))) { - var serviceName = match[1].toLowerCase(); - - // HACKETY HACK. needed to not match - // Meteor.loginWithToken. See XXX above. - if (Accounts[serviceName]) - services.push(match[1].toLowerCase()); - } - }); + + // First look for OAuth services. + var services = Package['accounts-oauth'] ? Accounts.oauth.serviceNames() : []; // Be equally kind to all login services. This also preserves // backwards-compatibility. (But maybe order should be // configurable?) services.sort(); - // ensure password is last - if (_.contains(services, 'password')) - services = _.without(services, 'password').concat(['password']); + // Add password, if it's there; it must come last. + if (Accounts._loginButtons.hasPasswordService()) + services.push('password'); return _.map(services, function(name) { return {name: name}; @@ -151,7 +131,7 @@ Accounts._loginButtons.getLoginServices = function () { }; Accounts._loginButtons.hasPasswordService = function () { - return Accounts.password; + return !!Package['accounts-password']; }; Accounts._loginButtons.dropdown = function () { diff --git a/package.js b/package.js index f2055e6..20e39b3 100644 --- a/package.js +++ b/package.js @@ -3,7 +3,18 @@ Package.describe({ }); Package.on_use(function (api) { - api.use(['accounts-urls', 'accounts-base', 'underscore', 'templating', 'bootstrap', 'jquery'], 'client'); + api.use(['accounts-base', 'underscore', 'templating', 'bootstrap', 'jquery', 'handlebars'], 'client'); + + // Export Accounts (etc) to packages using this one. + api.imply('accounts-base', ['client', 'server']); + + // Allow us to call Accounts.oauth.serviceNames, if there are any OAuth + // services. + api.use('accounts-oauth', {weak: true}); + // Allow us to directly test if accounts-password (which doesn't use + // Accounts.oauth.registerService) exists. + api.use('accounts-password', {weak: true}); + api.add_files([ 'accounts_ui.js',