From 1eceed28f9e866a23decf5c76ba25889ef90aa6a Mon Sep 17 00:00:00 2001 From: Nick Martin Date: Mon, 1 Oct 2012 13:44:14 -0700 Subject: [PATCH] Replace 'Meteor.accounts' with 'Accounts'. find . -name '*.js' -print0 | xargs -0 perl -pi -e 's/Meteor\.accounts/Accounts/g' --- examples/todos/accounts/config.js | 2 +- examples/todos/accounts/server/secrets.js | 4 +- examples/todos/accounts/services.js | 4 +- packages/accounts-base/accounts_client.js | 4 +- packages/accounts-base/accounts_common.js | 30 +++---- packages/accounts-base/accounts_server.js | 34 ++++---- packages/accounts-base/accounts_tests.js | 22 ++--- packages/accounts-base/localstorage_token.js | 52 ++++++------ packages/accounts-facebook/facebook_client.js | 12 +-- packages/accounts-facebook/facebook_common.js | 8 +- packages/accounts-facebook/facebook_server.js | 6 +- packages/accounts-google/google_client.js | 12 +-- packages/accounts-google/google_common.js | 8 +- packages/accounts-google/google_server.js | 10 +-- .../accounts-oauth-helper/oauth_client.js | 6 +- .../accounts-oauth-helper/oauth_common.js | 2 +- .../accounts-oauth-helper/oauth_server.js | 36 ++++---- .../accounts-oauth1-helper/oauth1_common.js | 2 +- .../accounts-oauth1-helper/oauth1_server.js | 24 +++--- .../accounts-oauth1-helper/oauth1_tests.js | 40 ++++----- .../accounts-oauth2-helper/oauth2_common.js | 2 +- .../accounts-oauth2-helper/oauth2_server.js | 10 +-- .../accounts-oauth2-helper/oauth2_tests.js | 36 ++++---- packages/accounts-password/email_templates.js | 8 +- .../accounts-password/email_tests_setup.js | 2 +- .../accounts-password/passwords_client.js | 8 +- .../accounts-password/passwords_common.js | 2 +- .../accounts-password/passwords_server.js | 76 ++++++++--------- packages/accounts-password/passwords_tests.js | 12 +-- .../passwords_tests_setup.js | 6 +- packages/accounts-twitter/twitter_client.js | 6 +- packages/accounts-twitter/twitter_common.js | 6 +- packages/accounts-twitter/twitter_server.js | 2 +- .../accounts-ui-unstyled/login_buttons.js | 82 +++++++++---------- packages/accounts-urls/url_client.js | 16 ++-- packages/accounts-urls/url_server.js | 14 ++-- packages/accounts-weibo/weibo_client.js | 6 +- packages/accounts-weibo/weibo_common.js | 12 +-- packages/accounts-weibo/weibo_server.js | 6 +- 39 files changed, 315 insertions(+), 315 deletions(-) diff --git a/examples/todos/accounts/config.js b/examples/todos/accounts/config.js index 55cd07f40f..cde224a4dd 100644 --- a/examples/todos/accounts/config.js +++ b/examples/todos/accounts/config.js @@ -1,4 +1,4 @@ -Meteor.accounts.config({ +Accounts.config({ requireEmail: false, requireUsername: false, validateEmails: true diff --git a/examples/todos/accounts/server/secrets.js b/examples/todos/accounts/server/secrets.js index f1463cdeff..86792b48ff 100644 --- a/examples/todos/accounts/server/secrets.js +++ b/examples/todos/accounts/server/secrets.js @@ -1,5 +1,5 @@ // Modify and uncomment the following lines to configure login services. // Also see accounts/services.js -// Meteor.accounts.facebook.setSecret('SECRET'); -// Meteor.accounts.google.setSecret('SECRET'); +// Accounts.facebook.setSecret('SECRET'); +// Accounts.google.setSecret('SECRET'); diff --git a/examples/todos/accounts/services.js b/examples/todos/accounts/services.js index 1ab4e5d6c2..8e2ad94ddb 100644 --- a/examples/todos/accounts/services.js +++ b/examples/todos/accounts/services.js @@ -1,5 +1,5 @@ // Modify and uncomment the following lines to configure login services. // Also see accounts/server/secrets.js -// Meteor.accounts.facebook.config('218833638237574', 'http://auth-todos.meteor.com'); -// Meteor.accounts.google.config('987846107089.apps.googleusercontent.com', 'http://auth-todos.meteor.com'); +// Accounts.facebook.config('218833638237574', 'http://auth-todos.meteor.com'); +// Accounts.google.config('987846107089.apps.googleusercontent.com', 'http://auth-todos.meteor.com'); diff --git a/packages/accounts-base/accounts_client.js b/packages/accounts-base/accounts_client.js index 4d8c6c02d2..c894b10f50 100644 --- a/packages/accounts-base/accounts_client.js +++ b/packages/accounts-base/accounts_client.js @@ -26,7 +26,7 @@ if (error) { callback && callback(error); } else { - Meteor.accounts.makeClientLoggedOut(); + Accounts.makeClientLoggedOut(); callback && callback(); } }); @@ -55,7 +55,7 @@ // loginServiceConfiguration subscription is ready. Used by // accounts-ui to hide the login button until we have all the // configuration loaded - Meteor.accounts.loginServicesConfigured = function () { + Accounts.loginServicesConfigured = function () { if (loginServicesConfigured) return true; diff --git a/packages/accounts-base/accounts_common.js b/packages/accounts-base/accounts_common.js index cee3fb010b..d3ae490a5a 100644 --- a/packages/accounts-base/accounts_common.js +++ b/packages/accounts-base/accounts_common.js @@ -1,9 +1,9 @@ -if (!Meteor.accounts) { - Meteor.accounts = {}; +if (!Accounts) { + Accounts = {}; } -if (!Meteor.accounts._options) { - Meteor.accounts._options = {}; +if (!Accounts._options) { + Accounts._options = {}; } // @param options {Object} an object with fields: @@ -11,13 +11,13 @@ if (!Meteor.accounts._options) { // - requireUsername {Boolean} // - validateEmails {Boolean} Send validation emails to all new users // via the signup form -Meteor.accounts.config = function(options) { - Meteor.accounts._options = options; +Accounts.config = function(options) { + Accounts._options = options; }; // internal login tokens collection. Never published. -Meteor.accounts._loginTokens = new Meteor.Collection( +Accounts._loginTokens = new Meteor.Collection( "accounts._loginTokens", null /*manager*/, null /*driver*/, @@ -27,7 +27,7 @@ Meteor.accounts._loginTokens = new Meteor.Collection( // table, and it is _really_ insecure to allow it as users could easily // steal sessions and impersonate other users. Users can override by // calling more allows later, if they really want. -Meteor.accounts._loginTokens.allow({}); +Accounts._loginTokens.allow({}); // Users table. Don't use the normal autopublish, since we want to hide @@ -43,7 +43,7 @@ Meteor.users = new Meteor.Collection( // Table containing documents with configuration options for each // login service -Meteor.accounts.configuration = new Meteor.Collection( +Accounts.configuration = new Meteor.Collection( "accounts._loginServiceConfiguration", null /*manager*/, null /*driver*/, @@ -56,18 +56,18 @@ Meteor.accounts.configuration = new Meteor.Collection( // Thrown when trying to use a login service which is not configured -Meteor.accounts.ConfigError = function(description) { +Accounts.ConfigError = function(description) { this.message = description; }; -Meteor.accounts.ConfigError.prototype = new Error(); -Meteor.accounts.ConfigError.prototype.name = 'Meteor.accounts.ConfigError'; +Accounts.ConfigError.prototype = new Error(); +Accounts.ConfigError.prototype.name = 'Accounts.ConfigError'; // Thrown when the user cancels the login process (eg, closes an oauth // popup, declines retina scan, etc) -Meteor.accounts.LoginCancelledError = function(description) { +Accounts.LoginCancelledError = function(description) { this.message = description; this.cancelled = true; }; -Meteor.accounts.LoginCancelledError.prototype = new Error(); -Meteor.accounts.LoginCancelledError.prototype.name = 'Meteor.accounts.LoginCancelledError'; +Accounts.LoginCancelledError.prototype = new Error(); +Accounts.LoginCancelledError.prototype.name = 'Accounts.LoginCancelledError'; diff --git a/packages/accounts-base/accounts_server.js b/packages/accounts-base/accounts_server.js index 90d152623f..d687ff58a3 100644 --- a/packages/accounts-base/accounts_server.js +++ b/packages/accounts-base/accounts_server.js @@ -20,7 +20,7 @@ } }); - Meteor.accounts._loginHandlers = []; + Accounts._loginHandlers = []; // Try all of the registered login handlers until one of them // doesn't return `undefined` (NOT null), meaning it handled this @@ -28,7 +28,7 @@ var tryAllLoginHandlers = function (options) { var result = undefined; - _.find(Meteor.accounts._loginHandlers, function(handler) { + _.find(Accounts._loginHandlers, function(handler) { var maybeResult = handler(options); if (maybeResult !== undefined) { @@ -51,14 +51,14 @@ // - `undefined`, meaning don't handle; // - `null`, meaning the user didn't actually log in; // - {id: userId, accessToken: *}, if the user logged in successfully. - Meteor.accounts.registerLoginHandler = function(handler) { - Meteor.accounts._loginHandlers.push(handler); + Accounts.registerLoginHandler = function(handler) { + Accounts._loginHandlers.push(handler); }; // support reconnecting using a meteor login token - Meteor.accounts.registerLoginHandler(function(options) { + Accounts.registerLoginHandler(function(options) { if (options.resume) { - var loginToken = Meteor.accounts._loginTokens + var loginToken = Accounts._loginTokens .findOne({_id: options.resume}); if (!loginToken) throw new Meteor.Error(403, "Couldn't find login token"); @@ -103,7 +103,7 @@ /// CREATE USER HOOKS /// var onCreateUserHook = null; - Meteor.accounts.onCreateUser = function (func) { + Accounts.onCreateUser = function (func) { if (onCreateUserHook) throw new Error("Can only call onCreateUser once"); else @@ -117,18 +117,18 @@ ['services', 'username', 'email', 'emails']))) throw new Meteor.Error(400, "Disallowed fields in extra"); - if (Meteor.accounts._options.requireEmail && + if (Accounts._options.requireEmail && (!user.emails || !user.emails.length)) throw new Meteor.Error(400, "Email address required."); - if (Meteor.accounts._options.requireUsername && + if (Accounts._options.requireUsername && !user.username) throw new Meteor.Error(400, "Username required."); return _.extend(user, extra); }; - Meteor.accounts.onCreateUserHook = function (options, extra, user) { + Accounts.onCreateUserHook = function (options, extra, user) { // add created at timestamp (and protect passed in user object from // modification) user = _.extend({createdAt: +(new Date)}, user); @@ -169,7 +169,7 @@ }; var validateNewUserHooks = []; - Meteor.accounts.validateNewUser = function (func) { + Accounts.validateNewUser = function (func) { validateNewUserHooks.push(func); }; @@ -184,7 +184,7 @@ // - services {Object} e.g. {facebook: {id: (facebook user id), ...}} // @param extra {Object, optional} Any additional fields to place on the user objet // @returns {String} userId - Meteor.accounts.updateOrCreateUser = function(options, extra) { + Accounts.updateOrCreateUser = function(options, extra) { extra = extra || {}; if (_.keys(options.services).length !== 1) @@ -212,7 +212,7 @@ user = { services: attrs }; - user = Meteor.accounts.onCreateUserHook(options, extra, user); + user = Accounts.onCreateUserHook(options, extra, user); return Meteor.users.insert(user); } }; @@ -242,15 +242,15 @@ // Publish all login service configuration fields other than secret. Meteor.publish("loginServiceConfiguration", function () { - return Meteor.accounts.configuration.find({}, {fields: {secret: 0}}); + return Accounts.configuration.find({}, {fields: {secret: 0}}); }, {is_auto: true}); // not techincally autopublish, but stops the warning. // Allow a one-time configuration for a login service. - Meteor.accounts.configuration.allow({}); // disallow mutators + Accounts.configuration.allow({}); // disallow mutators Meteor.methods({ "configureLoginService": function(options) { - if (!Meteor.accounts.configuration.findOne({service: options.service})) - Meteor.accounts.configuration.insert(options); + if (!Accounts.configuration.findOne({service: options.service})) + Accounts.configuration.insert(options); else throw new Meteor.Error(403, "Service " + options.service + " already configured"); } diff --git a/packages/accounts-base/accounts_tests.js b/packages/accounts-base/accounts_tests.js index 7147e9dbd9..e5086897b3 100644 --- a/packages/accounts-base/accounts_tests.js +++ b/packages/accounts-base/accounts_tests.js @@ -5,13 +5,13 @@ Tinytest.add('accounts - updateOrCreateUser', function (test) { // create an account with facebook - var uid1 = Meteor.accounts.updateOrCreateUser( + var uid1 = Accounts.updateOrCreateUser( {services: {facebook: {id: facebookId}}}, {foo: 1}); test.equal(Meteor.users.find({"services.facebook.id": facebookId}).count(), 1); test.equal(Meteor.users.findOne({"services.facebook.id": facebookId}).foo, 1); // create again with the same id, see that we get the same user - var uid2 = Meteor.accounts.updateOrCreateUser( + var uid2 = Accounts.updateOrCreateUser( {services: {facebook: {id: facebookId}}}, {foo: 1000, bar: 2}); // foo: 1000 shouldn't overwrite test.equal(uid1, uid2); test.equal(Meteor.users.find({"services.facebook.id": facebookId}).count(), 1); @@ -23,9 +23,9 @@ Tinytest.add('accounts - updateOrCreateUser', function (test) { // users that have different service ids get different users - uid1 = Meteor.accounts.updateOrCreateUser( + uid1 = Accounts.updateOrCreateUser( {services: {weibo: {id: weiboId1}}}, {foo: 1}); - uid2 = Meteor.accounts.updateOrCreateUser( + uid2 = Accounts.updateOrCreateUser( {services: {weibo: {id: weiboId2}}}, {bar: 2}); test.equal(Meteor.users.find({"services.weibo.id": {$in: [weiboId1, weiboId2]}}).count(), 2); test.equal(Meteor.users.findOne({"services.weibo.id": weiboId1}).foo, 1); @@ -45,7 +45,7 @@ Tinytest.add('accounts - onCreateUserHook username', function (test) { }; // user does not already exist. return a user object with fields set. - var userOut = Meteor.accounts.onCreateUserHook( + var userOut = Accounts.onCreateUserHook( userIn, {profile: {name: 'Foo Bar'}}, userIn @@ -60,7 +60,7 @@ Tinytest.add('accounts - onCreateUserHook username', function (test) { // run the hook again. now the user exists, so it throws an error. test.throws(function () { - Meteor.accounts.onCreateUserHook( + Accounts.onCreateUserHook( userIn, {profile: {name: 'Foo Bar'}}, userIn @@ -82,7 +82,7 @@ Tinytest.add('accounts - onCreateUserHook email', function (test) { }; // user does not already exist. return a user object with fields set. - var userOut = Meteor.accounts.onCreateUserHook( + var userOut = Accounts.onCreateUserHook( userIn, {profile: {name: 'Foo Bar'}}, userIn @@ -98,7 +98,7 @@ Tinytest.add('accounts - onCreateUserHook email', function (test) { // run the hook again with the exact same emails. // run the hook again. now the user exists, so it throws an error. test.throws(function () { - Meteor.accounts.onCreateUserHook( + Accounts.onCreateUserHook( userIn, {profile: {name: 'Foo Bar'}}, userIn @@ -107,20 +107,20 @@ Tinytest.add('accounts - onCreateUserHook email', function (test) { // now with only one of them. test.throws(function () { - Meteor.accounts.onCreateUserHook( + Accounts.onCreateUserHook( {}, {}, {emails: [{address: email1}]} ); }); test.throws(function () { - Meteor.accounts.onCreateUserHook( + Accounts.onCreateUserHook( {}, {}, {emails: [{address: email2}]} ); }); // a third email works. - var user3 = Meteor.accounts.onCreateUserHook( + var user3 = Accounts.onCreateUserHook( {}, {}, {emails: [{address: email3}]} ); test.equal(typeof userOut.createdAt, 'number'); diff --git a/packages/accounts-base/localstorage_token.js b/packages/accounts-base/localstorage_token.js index 9d14a7fcfa..43391a88de 100644 --- a/packages/accounts-base/localstorage_token.js +++ b/packages/accounts-base/localstorage_token.js @@ -3,45 +3,45 @@ var loginTokenKey = "Meteor.loginToken"; var userIdKey = "Meteor.userId"; - Meteor.accounts.storeLoginToken = function(userId, token) { + Accounts.storeLoginToken = function(userId, token) { localStorage.setItem(userIdKey, userId); localStorage.setItem(loginTokenKey, token); // to ensure that the localstorage poller doesn't end up trying to // connect a second time - Meteor.accounts._lastLoginTokenWhenPolled = token; + Accounts._lastLoginTokenWhenPolled = token; }; - Meteor.accounts.unstoreLoginToken = function() { + Accounts.unstoreLoginToken = function() { localStorage.removeItem(userIdKey); localStorage.removeItem(loginTokenKey); // to ensure that the localstorage poller doesn't end up trying to // connect a second time - Meteor.accounts._lastLoginTokenWhenPolled = null; + Accounts._lastLoginTokenWhenPolled = null; }; - Meteor.accounts.storedLoginToken = function() { + Accounts.storedLoginToken = function() { return localStorage.getItem(loginTokenKey); }; - Meteor.accounts.storedUserId = function() { + Accounts.storedUserId = function() { return localStorage.getItem(userIdKey); }; - Meteor.accounts.makeClientLoggedOut = function() { - Meteor.accounts.unstoreLoginToken(); + Accounts.makeClientLoggedOut = function() { + Accounts.unstoreLoginToken(); Meteor.default_connection.setUserId(null); Meteor.default_connection.onReconnect = null; }; - Meteor.accounts.makeClientLoggedIn = function(userId, token) { - Meteor.accounts.storeLoginToken(userId, token); + Accounts.makeClientLoggedIn = function(userId, token) { + Accounts.storeLoginToken(userId, token); Meteor.default_connection.setUserId(userId); Meteor.default_connection.onReconnect = function() { Meteor.apply('login', [{resume: token}], {wait: true}, function(error, result) { if (error) { - Meteor.accounts.makeClientLoggedOut(); + Accounts.makeClientLoggedOut(); throw error; } else { // nothing to do @@ -62,49 +62,49 @@ Meteor.loginWithToken = function (token, errorCallback) { throw error; } - Meteor.accounts.makeClientLoggedIn(result.id, result.token); + Accounts.makeClientLoggedIn(result.id, result.token); }); }; -if (!Meteor.accounts._preventAutoLogin) { +if (!Accounts._preventAutoLogin) { // Immediately try to log in via local storage, so that any DDP // messages are sent after we have established our user account - var token = Meteor.accounts.storedLoginToken(); + var token = Accounts.storedLoginToken(); if (token) { // On startup, optimistically present us as logged in while the // request is in flight. This reduces page flicker on startup. - var userId = Meteor.accounts.storedUserId(); + var userId = Accounts.storedUserId(); userId && Meteor.default_connection.setUserId(userId); Meteor.loginWithToken(token, function () { - Meteor.accounts.makeClientLoggedOut(); + Accounts.makeClientLoggedOut(); }); } } // Poll local storage every 3 seconds to login if someone logged in in // another tab -Meteor.accounts._lastLoginTokenWhenPolled = token; -Meteor.accounts._pollStoredLoginToken = function() { - if (Meteor.accounts._preventAutoLogin) +Accounts._lastLoginTokenWhenPolled = token; +Accounts._pollStoredLoginToken = function() { + if (Accounts._preventAutoLogin) return; - var currentLoginToken = Meteor.accounts.storedLoginToken(); + var currentLoginToken = Accounts.storedLoginToken(); // != instead of !== just to make sure undefined and null are treated the same - if (Meteor.accounts._lastLoginTokenWhenPolled != currentLoginToken) { + if (Accounts._lastLoginTokenWhenPolled != currentLoginToken) { if (currentLoginToken) Meteor.loginWithToken(currentLoginToken); // XXX should we pass a callback here? else Meteor.logout(); } - Meteor.accounts._lastLoginTokenWhenPolled = currentLoginToken; + Accounts._lastLoginTokenWhenPolled = currentLoginToken; }; // Semi-internal API. Call this function to re-enable auto login after // if it was disabled at startup. -Meteor.accounts._enableAutoLogin = function () { - Meteor.accounts._preventAutoLogin = false; - Meteor.accounts._pollStoredLoginToken(); +Accounts._enableAutoLogin = function () { + Accounts._preventAutoLogin = false; + Accounts._pollStoredLoginToken(); }; -setInterval(Meteor.accounts._pollStoredLoginToken, 3000); +setInterval(Accounts._pollStoredLoginToken, 3000); diff --git a/packages/accounts-facebook/facebook_client.js b/packages/accounts-facebook/facebook_client.js index e92e3cbd1a..a3f348cb4f 100644 --- a/packages/accounts-facebook/facebook_client.js +++ b/packages/accounts-facebook/facebook_client.js @@ -1,8 +1,8 @@ (function () { Meteor.loginWithFacebook = function (callback) { - var config = Meteor.accounts.configuration.findOne({service: 'facebook'}); + var config = Accounts.configuration.findOne({service: 'facebook'}); if (!config) { - callback && callback(new Meteor.accounts.ConfigError("Service not configured")); + callback && callback(new Accounts.ConfigError("Service not configured")); return; } @@ -11,16 +11,16 @@ var display = mobile ? 'touch' : 'popup'; var scope = "email"; - if (Meteor.accounts.facebook._options && - Meteor.accounts.facebook._options.scope) - scope = Meteor.accounts.facebook._options.scope.join(','); + if (Accounts.facebook._options && + Accounts.facebook._options.scope) + scope = Accounts.facebook._options.scope.join(','); var loginUrl = 'https://www.facebook.com/dialog/oauth?client_id=' + config.appId + '&redirect_uri=' + Meteor.absoluteUrl('_oauth/facebook?close') + '&display=' + display + '&scope=' + scope + '&state=' + state; - Meteor.accounts.oauth.initiateLogin(state, loginUrl, callback); + Accounts.oauth.initiateLogin(state, loginUrl, callback); }; })(); diff --git a/packages/accounts-facebook/facebook_common.js b/packages/accounts-facebook/facebook_common.js index 2c1fca99f9..d04176578e 100644 --- a/packages/accounts-facebook/facebook_common.js +++ b/packages/accounts-facebook/facebook_common.js @@ -1,7 +1,7 @@ -if (!Meteor.accounts.facebook) { - Meteor.accounts.facebook = {}; +if (!Accounts.facebook) { + Accounts.facebook = {}; } -Meteor.accounts.facebook.config = function(options) { - Meteor.accounts.facebook._options = options; +Accounts.facebook.config = function(options) { + Accounts.facebook._options = options; }; diff --git a/packages/accounts-facebook/facebook_server.js b/packages/accounts-facebook/facebook_server.js index 0ce7db31c4..07bf56c52b 100644 --- a/packages/accounts-facebook/facebook_server.js +++ b/packages/accounts-facebook/facebook_server.js @@ -1,6 +1,6 @@ (function () { - Meteor.accounts.oauth.registerService('facebook', 2, function(query) { + Accounts.oauth.registerService('facebook', 2, function(query) { var accessToken = getAccessToken(query); var identity = getIdentity(accessToken); @@ -18,9 +18,9 @@ }); var getAccessToken = function (query) { - var config = Meteor.accounts.configuration.findOne({service: 'facebook'}); + var config = Accounts.configuration.findOne({service: 'facebook'}); if (!config) - throw new Meteor.accounts.ConfigError("Service not configured"); + throw new Accounts.ConfigError("Service not configured"); // Request an access token var result = Meteor.http.get( diff --git a/packages/accounts-google/google_client.js b/packages/accounts-google/google_client.js index 81cc861de9..697a9c6a4f 100644 --- a/packages/accounts-google/google_client.js +++ b/packages/accounts-google/google_client.js @@ -1,8 +1,8 @@ (function () { Meteor.loginWithGoogle = function (callback) { - var config = Meteor.accounts.configuration.findOne({service: 'google'}); + var config = Accounts.configuration.findOne({service: 'google'}); if (!config) { - callback && callback(new Meteor.accounts.ConfigError("Service not configured")); + callback && callback(new Accounts.ConfigError("Service not configured")); return; } @@ -11,9 +11,9 @@ // 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 (Meteor.accounts.google._options && - Meteor.accounts.google._options.scope) - scope = Meteor.accounts.google._options.scope; + if (Accounts.google._options && + Accounts.google._options.scope) + scope = Accounts.google._options.scope; scope = _.union(scope, required_scope); var flat_scope = _.map(scope, encodeURIComponent).join('+'); @@ -28,7 +28,7 @@ '&redirect_uri=' + Meteor.absoluteUrl('_oauth/google?close') + '&state=' + state; - Meteor.accounts.oauth.initiateLogin(state, loginUrl, callback); + Accounts.oauth.initiateLogin(state, loginUrl, callback); }; }) (); diff --git a/packages/accounts-google/google_common.js b/packages/accounts-google/google_common.js index b68429d14b..8ca64f59f9 100644 --- a/packages/accounts-google/google_common.js +++ b/packages/accounts-google/google_common.js @@ -1,7 +1,7 @@ -if (!Meteor.accounts.google) { - Meteor.accounts.google = {}; +if (!Accounts.google) { + Accounts.google = {}; } -Meteor.accounts.google.config = function(options) { - Meteor.accounts.google._options = options; +Accounts.google.config = function(options) { + Accounts.google._options = options; }; diff --git a/packages/accounts-google/google_server.js b/packages/accounts-google/google_server.js index 85903a10be..8da55b0fb4 100644 --- a/packages/accounts-google/google_server.js +++ b/packages/accounts-google/google_server.js @@ -1,10 +1,10 @@ (function () { - Meteor.accounts.google.setSecret = function (secret) { - Meteor.accounts.google._secret = secret; + Accounts.google.setSecret = function (secret) { + Accounts.google._secret = secret; }; - Meteor.accounts.oauth.registerService('google', 2, function(query) { + Accounts.oauth.registerService('google', 2, function(query) { var accessToken = getAccessToken(query); var identity = getIdentity(accessToken); @@ -22,9 +22,9 @@ }); var getAccessToken = function (query) { - var config = Meteor.accounts.configuration.findOne({service: 'google'}); + var config = Accounts.configuration.findOne({service: 'google'}); if (!config) - throw new Meteor.accounts.ConfigError("Service not configured"); + throw new Accounts.ConfigError("Service not configured"); var result = Meteor.http.post( "https://accounts.google.com/o/oauth2/token", {params: { diff --git a/packages/accounts-oauth-helper/oauth_client.js b/packages/accounts-oauth-helper/oauth_client.js index 763390df01..16dfdacbff 100644 --- a/packages/accounts-oauth-helper/oauth_client.js +++ b/packages/accounts-oauth-helper/oauth_client.js @@ -6,7 +6,7 @@ // @param callback {Function} Callback function to call on // completion. Takes one argument, null on success, or Error on // error. - Meteor.accounts.oauth.initiateLogin = function(state, url, callback) { + Accounts.oauth.initiateLogin = function(state, url, callback) { // XXX these dimensions worked well for facebook and google, but // it's sort of weird to have these here. Maybe an optional // argument instead? @@ -45,9 +45,9 @@ // the server doesn't see the request but does close the // window. This seems unlikely. callback && - callback(new Meteor.accounts.LoginCancelledError("Popup closed")); + callback(new Accounts.LoginCancelledError("Popup closed")); } else { - Meteor.accounts.makeClientLoggedIn(result.id, result.token); + Accounts.makeClientLoggedIn(result.id, result.token); callback && callback(); } }); diff --git a/packages/accounts-oauth-helper/oauth_common.js b/packages/accounts-oauth-helper/oauth_common.js index 3c6e8b8558..d47da20292 100644 --- a/packages/accounts-oauth-helper/oauth_common.js +++ b/packages/accounts-oauth-helper/oauth_common.js @@ -1 +1 @@ -Meteor.accounts.oauth = {}; \ No newline at end of file +Accounts.oauth = {}; \ No newline at end of file diff --git a/packages/accounts-oauth-helper/oauth_server.js b/packages/accounts-oauth-helper/oauth_server.js index 15f8e2e6a5..2fc7e6eef5 100644 --- a/packages/accounts-oauth-helper/oauth_server.js +++ b/packages/accounts-oauth-helper/oauth_server.js @@ -1,7 +1,7 @@ (function () { var connect = __meteor_bootstrap__.require("connect"); - Meteor.accounts.oauth._services = {}; + Accounts.oauth._services = {}; // Register a handler for an OAuth service. The handler will be called // when we get an incoming http request on /_oauth/{serviceName}. This @@ -15,13 +15,13 @@ // - (For OAuth2 only) query {Object} parameters passed in query string // - return value is: // - {options: (options), extra: (optional extra)} (same as the - // arguments to Meteor.accounts.updateOrCreateUser) + // arguments to Accounts.updateOrCreateUser) // - `null` if the user declined to give permissions - Meteor.accounts.oauth.registerService = function (name, version, handleOauthRequest) { - if (Meteor.accounts.oauth._services[name]) + Accounts.oauth.registerService = function (name, version, handleOauthRequest) { + if (Accounts.oauth._services[name]) throw new Error("Already registered the " + name + " OAuth service"); - Meteor.accounts.oauth._services[name] = { + Accounts.oauth._services[name] = { serviceName: name, version: version, handleOauthRequest: handleOauthRequest @@ -34,14 +34,14 @@ // method is called. Maps state --> return value of `login` // // XXX we should periodically clear old entries - Meteor.accounts.oauth._loginResultForState = {}; + Accounts.oauth._loginResultForState = {}; // Listen to calls to `login` with an oauth option set - Meteor.accounts.registerLoginHandler(function (options) { + Accounts.registerLoginHandler(function (options) { if (!options.oauth) return undefined; // don't handle - var result = Meteor.accounts.oauth._loginResultForState[options.oauth.state]; + var result = Accounts.oauth._loginResultForState[options.oauth.state]; if (result === undefined) // not using `!result` since can be null // We weren't notified of the user authorizing the login. return null; @@ -61,11 +61,11 @@ // calls and nothing else is wrapping this in a fiber // automatically Fiber(function () { - Meteor.accounts.oauth._middleware(req, res, next); + Accounts.oauth._middleware(req, res, next); }).run(); }); - Meteor.accounts.oauth._middleware = function (req, res, next) { + Accounts.oauth._middleware = function (req, res, next) { // Make sure to catch any exceptions because otherwise we'd crash // the runner try { @@ -76,7 +76,7 @@ return; } - var service = Meteor.accounts.oauth._services[serviceName]; + var service = Accounts.oauth._services[serviceName]; // Skip everything if there's no service set by the oauth middleware if (!service) @@ -86,9 +86,9 @@ ensureConfigured(serviceName); if (service.version === 1) - Meteor.accounts.oauth1._handleRequest(service, req.query, res); + Accounts.oauth1._handleRequest(service, req.query, res); else if (service.version === 2) - Meteor.accounts.oauth2._handleRequest(service, req.query, res); + Accounts.oauth2._handleRequest(service, req.query, res); else throw new Error("Unexpected OAuth version " + service.version); } catch (err) { @@ -100,7 +100,7 @@ // we were passed. But then the developer wouldn't be able to // style the error or react to it in any way. if (req.query.state && err instanceof Error) - Meteor.accounts.oauth._loginResultForState[req.query.state] = err; + Accounts.oauth._loginResultForState[req.query.state] = err; // also log to the server console, so the developer sees it. Meteor._debug("Exception in oauth request handler", err); @@ -108,7 +108,7 @@ // XXX the following is actually wrong. if someone wants to // redirect rather than close once we are done with the OAuth // flow, as supported by - // Meteor.accounts.oauth_renderOauthResults, this will still + // Accounts.oauth_renderOauthResults, this will still // close the popup instead. Once we fully support the redirect // flow (by supporting that in places such as // packages/facebook/facebook_client.js) we should revisit this. @@ -142,12 +142,12 @@ // Make sure we're configured var ensureConfigured = function(serviceName) { - if (!Meteor.accounts.configuration.findOne({service: serviceName})) { - throw new Meteor.accounts.ConfigError("Service not configured"); + if (!Accounts.configuration.findOne({service: serviceName})) { + throw new Accounts.ConfigError("Service not configured"); }; }; - Meteor.accounts.oauth._renderOauthResults = function(res, query) { + Accounts.oauth._renderOauthResults = function(res, query) { // We support ?close and ?redirect=URL. Any other query should // just serve a blank page if ('close' in query) { // check with 'in' because we don't set a value diff --git a/packages/accounts-oauth1-helper/oauth1_common.js b/packages/accounts-oauth1-helper/oauth1_common.js index 3b746c7e43..d4ce446298 100644 --- a/packages/accounts-oauth1-helper/oauth1_common.js +++ b/packages/accounts-oauth1-helper/oauth1_common.js @@ -1 +1 @@ -Meteor.accounts.oauth1 = {}; \ No newline at end of file +Accounts.oauth1 = {}; \ No newline at end of file diff --git a/packages/accounts-oauth1-helper/oauth1_server.js b/packages/accounts-oauth1-helper/oauth1_server.js index 4025862d4d..b6a20bf30e 100644 --- a/packages/accounts-oauth1-helper/oauth1_server.js +++ b/packages/accounts-oauth1-helper/oauth1_server.js @@ -2,17 +2,17 @@ var connect = __meteor_bootstrap__.require("connect"); // A place to store request tokens pending verification - Meteor.accounts.oauth1._requestTokens = {}; + Accounts.oauth1._requestTokens = {}; // connect middleware - Meteor.accounts.oauth1._handleRequest = function (service, query, res) { + Accounts.oauth1._handleRequest = function (service, query, res) { - var config = Meteor.accounts.configuration.findOne({service: service.serviceName}); + var config = Accounts.configuration.findOne({service: service.serviceName}); if (!config) { - throw new Meteor.accounts.ConfigError("Service " + service.serviceName + " not configured"); + throw new Accounts.ConfigError("Service " + service.serviceName + " not configured"); } - var urls = Meteor.accounts[service.serviceName]._urls; + var urls = Accounts[service.serviceName]._urls; var oauthBinding = new OAuth1Binding( config.consumerKey, config.secret, urls); @@ -23,7 +23,7 @@ oauthBinding.prepareRequestToken(query.requestTokenAndRedirect); // Keep track of request token so we can verify it on the next step - Meteor.accounts.oauth1._requestTokens[query.state] = oauthBinding.requestToken; + Accounts.oauth1._requestTokens[query.state] = oauthBinding.requestToken; // redirect to provider login, which will redirect back to "step 2" below var redirectUrl = urls.authenticate + '?oauth_token=' + oauthBinding.requestToken; @@ -36,8 +36,8 @@ // token and access token secret and log in as user // Get the user's request token so we can verify it and clear it - var requestToken = Meteor.accounts.oauth1._requestTokens[query.state]; - delete Meteor.accounts.oauth1._requestTokens[query.state]; + var requestToken = Accounts.oauth1._requestTokens[query.state]; + delete Accounts.oauth1._requestTokens[query.state]; // Verify user authorized access and the oauth_token matches // the requestToken from previous step @@ -51,22 +51,22 @@ // Get or create user id var oauthResult = service.handleOauthRequest(oauthBinding); - var userId = Meteor.accounts.updateOrCreateUser( + var userId = Accounts.updateOrCreateUser( oauthResult.options, oauthResult.extra); // Generate and store a login token for reconnect // XXX this could go in accounts_server.js instead - var loginToken = Meteor.accounts._loginTokens.insert({userId: userId}); + var loginToken = Accounts._loginTokens.insert({userId: userId}); // Store results to subsequent call to `login` - Meteor.accounts.oauth._loginResultForState[query.state] = + Accounts.oauth._loginResultForState[query.state] = {token: loginToken, id: userId}; } } // Either close the window, redirect, or render nothing // if all else fails - Meteor.accounts.oauth._renderOauthResults(res, query); + Accounts.oauth._renderOauthResults(res, query); }; })(); diff --git a/packages/accounts-oauth1-helper/oauth1_tests.js b/packages/accounts-oauth1-helper/oauth1_tests.js index e081ed7c1c..856e40c625 100644 --- a/packages/accounts-oauth1-helper/oauth1_tests.js +++ b/packages/accounts-oauth1-helper/oauth1_tests.js @@ -14,16 +14,16 @@ Tinytest.add("oauth1 - loginResultForState is stored", function (test) { // XXX XXX test isolation fail! Avital: but actually -- why would // we run server tests more than once? or even more so in parallel? - Meteor.accounts._loginTokens.remove({}); - Meteor.accounts.oauth._loginResultForState = {}; - Meteor.accounts.oauth._services = {}; + Accounts._loginTokens.remove({}); + Accounts.oauth._loginResultForState = {}; + Accounts.oauth._services = {}; - if (!Meteor.accounts.configuration.findOne({service: 'twitterfoo'})) - Meteor.accounts.configuration.insert({service: 'twitterfoo'}); - Meteor.accounts.twitterfoo = {}; + if (!Accounts.configuration.findOne({service: 'twitterfoo'})) + Accounts.configuration.insert({service: 'twitterfoo'}); + Accounts.twitterfoo = {}; // register a fake login service - twitterfoo - Meteor.accounts.oauth.registerService("twitterfoo", 1, function (query) { + Accounts.oauth.registerService("twitterfoo", 1, function (query) { return { options: { services: { @@ -39,7 +39,7 @@ Tinytest.add("oauth1 - loginResultForState is stored", function (test) { }); // simulate logging in using twitterfoo - Meteor.accounts.oauth1._requestTokens['STATE'] = twitterfooAccessToken; + Accounts.oauth1._requestTokens['STATE'] = twitterfooAccessToken; var req = { method: "POST", @@ -50,7 +50,7 @@ Tinytest.add("oauth1 - loginResultForState is stored", function (test) { } }; - Meteor.accounts.oauth._middleware(req, new http.ServerResponse(req)); + Accounts.oauth._middleware(req, new http.ServerResponse(req)); // verify that a user is created var user = Meteor.users.findOne({"services.twitter.screenName": twitterfooName}); @@ -59,14 +59,14 @@ Tinytest.add("oauth1 - loginResultForState is stored", function (test) { test.equal(user.services.twitter.accessTokenSecret, twitterfooAccessTokenSecret); // and that that user has a login token - var token = Meteor.accounts._loginTokens.findOne({userId: user._id}); + var token = Accounts._loginTokens.findOne({userId: user._id}); test.notEqual(token, undefined); // and that the login result for that user is prepared test.equal( - Meteor.accounts.oauth._loginResultForState['STATE'].id, user._id); + Accounts.oauth._loginResultForState['STATE'].id, user._id); test.equal( - Meteor.accounts.oauth._loginResultForState['STATE'].token, token._id); + Accounts.oauth._loginResultForState['STATE'].token, token._id); }); @@ -78,15 +78,15 @@ Tinytest.add("oauth1 - error in user creation", function (test) { var twitterfailAccessToken = Meteor.uuid(); var twitterfailAccessTokenSecret = Meteor.uuid(); - if (!Meteor.accounts.configuration.findOne({service: 'twitterfail'})) - Meteor.accounts.configuration.insert({service: 'twitterfail'}); - Meteor.accounts.twitterfail = {}; + if (!Accounts.configuration.findOne({service: 'twitterfail'})) + Accounts.configuration.insert({service: 'twitterfail'}); + Accounts.twitterfail = {}; // Wire up access token so that verification passes - Meteor.accounts.oauth1._requestTokens[state] = twitterfailAccessToken; + Accounts.oauth1._requestTokens[state] = twitterfailAccessToken; // register a failing login service - Meteor.accounts.oauth.registerService("twitterfail", 1, function (query) { + Accounts.oauth.registerService("twitterfail", 1, function (query) { return { options: { services: { @@ -106,7 +106,7 @@ Tinytest.add("oauth1 - error in user creation", function (test) { // a way to fail new users. duplicated from passwords_tests, but // shouldn't hurt. - Meteor.accounts.validateNewUser(function (user) { + Accounts.validateNewUser(function (user) { return !user.invalid; }); @@ -121,14 +121,14 @@ Tinytest.add("oauth1 - error in user creation", function (test) { } }; - Meteor.accounts.oauth._middleware(req, new http.ServerResponse(req)); + Accounts.oauth._middleware(req, new http.ServerResponse(req)); // verify that a user is not created var user = Meteor.users.findOne({"services.twitter.screenName": twitterfailName}); test.equal(user, undefined); // verify an error is stored in login state - test.equal(Meteor.accounts.oauth._loginResultForState[state].error, 403); + test.equal(Accounts.oauth._loginResultForState[state].error, 403); // verify error is handed back to login method. test.throws(function () { diff --git a/packages/accounts-oauth2-helper/oauth2_common.js b/packages/accounts-oauth2-helper/oauth2_common.js index cb23a48c2d..0012a34cee 100644 --- a/packages/accounts-oauth2-helper/oauth2_common.js +++ b/packages/accounts-oauth2-helper/oauth2_common.js @@ -1 +1 @@ -Meteor.accounts.oauth2 = {}; \ No newline at end of file +Accounts.oauth2 = {}; \ No newline at end of file diff --git a/packages/accounts-oauth2-helper/oauth2_server.js b/packages/accounts-oauth2-helper/oauth2_server.js index 718d7fd4b6..3e75759947 100644 --- a/packages/accounts-oauth2-helper/oauth2_server.js +++ b/packages/accounts-oauth2-helper/oauth2_server.js @@ -2,7 +2,7 @@ var connect = __meteor_bootstrap__.require("connect"); // connect middleware - Meteor.accounts.oauth2._handleRequest = function (service, query, res) { + Accounts.oauth2._handleRequest = function (service, query, res) { // check if user authorized access if (!query.error) { // Prepare the login results before returning. This way the @@ -11,21 +11,21 @@ // Get or create user id var oauthResult = service.handleOauthRequest(query); - var userId = Meteor.accounts.updateOrCreateUser( + var userId = Accounts.updateOrCreateUser( oauthResult.options, oauthResult.extra); // Generate and store a login token for reconnect // XXX this could go in accounts_server.js instead - var loginToken = Meteor.accounts._loginTokens.insert({userId: userId}); + var loginToken = Accounts._loginTokens.insert({userId: userId}); // Store results to subsequent call to `login` - Meteor.accounts.oauth._loginResultForState[query.state] = + Accounts.oauth._loginResultForState[query.state] = {token: loginToken, id: userId}; } // Either close the window, redirect, or render nothing // if all else fails - Meteor.accounts.oauth._renderOauthResults(res, query); + Accounts.oauth._renderOauthResults(res, query); }; })(); diff --git a/packages/accounts-oauth2-helper/oauth2_tests.js b/packages/accounts-oauth2-helper/oauth2_tests.js index 56171fec8b..d1da4d311e 100644 --- a/packages/accounts-oauth2-helper/oauth2_tests.js +++ b/packages/accounts-oauth2-helper/oauth2_tests.js @@ -4,16 +4,16 @@ Tinytest.add("oauth2 - loginResultForState is stored", function (test) { // XXX XXX test isolation fail! Avital: but actually -- why would // we run server tests more than once? or even more so in parallel? - Meteor.accounts._loginTokens.remove({}); - Meteor.accounts.oauth._loginResultForState = {}; - Meteor.accounts.oauth._services = {}; + Accounts._loginTokens.remove({}); + Accounts.oauth._loginResultForState = {}; + Accounts.oauth._services = {}; - if (!Meteor.accounts.configuration.findOne({service: 'foobook'})) - Meteor.accounts.configuration.insert({service: 'foobook'}); - Meteor.accounts.foobook = {}; + if (!Accounts.configuration.findOne({service: 'foobook'})) + Accounts.configuration.insert({service: 'foobook'}); + Accounts.foobook = {}; // register a fake login service - foobook - Meteor.accounts.oauth.registerService("foobook", 2, function (query) { + Accounts.oauth.registerService("foobook", 2, function (query) { return { options: { services: {foobook: {id: foobookId}} @@ -25,7 +25,7 @@ Tinytest.add("oauth2 - loginResultForState is stored", function (test) { var req = {method: "POST", url: "/_oauth/foobook?close", query: {state: "STATE"}}; - Meteor.accounts.oauth._middleware(req, new http.ServerResponse(req)); + Accounts.oauth._middleware(req, new http.ServerResponse(req)); // verify that a user is created var user = Meteor.users.findOne({"services.foobook.id": foobookId}); @@ -33,14 +33,14 @@ Tinytest.add("oauth2 - loginResultForState is stored", function (test) { test.equal(user.services.foobook.id, foobookId); // and that that user has a login token - var token = Meteor.accounts._loginTokens.findOne({userId: user._id}); + var token = Accounts._loginTokens.findOne({userId: user._id}); test.notEqual(token, undefined); // and that the login result for that user is prepared test.equal( - Meteor.accounts.oauth._loginResultForState['STATE'].id, user._id); + Accounts.oauth._loginResultForState['STATE'].id, user._id); test.equal( - Meteor.accounts.oauth._loginResultForState['STATE'].token, token._id); + Accounts.oauth._loginResultForState['STATE'].token, token._id); }); @@ -49,12 +49,12 @@ Tinytest.add("oauth2 - error in user creation", function (test) { var state = Meteor.uuid(); var failbookId = Meteor.uuid(); - if (!Meteor.accounts.configuration.findOne({service: 'failbook'})) - Meteor.accounts.configuration.insert({service: 'failbook'}); - Meteor.accounts.failbook = {}; + if (!Accounts.configuration.findOne({service: 'failbook'})) + Accounts.configuration.insert({service: 'failbook'}); + Accounts.failbook = {}; // register a failing login service - Meteor.accounts.oauth.registerService("failbook", 2, function (query) { + Accounts.oauth.registerService("failbook", 2, function (query) { return { options: { services: {failbook: {id: failbookId}} @@ -67,7 +67,7 @@ Tinytest.add("oauth2 - error in user creation", function (test) { // a way to fail new users. duplicated from passwords_tests, but // shouldn't hurt. - Meteor.accounts.validateNewUser(function (user) { + Accounts.validateNewUser(function (user) { return !user.invalid; }); @@ -76,14 +76,14 @@ Tinytest.add("oauth2 - error in user creation", function (test) { var req = {method: "POST", url: "/_oauth/failbook?close", query: {state: state}}; - Meteor.accounts.oauth._middleware(req, new http.ServerResponse(req)); + Accounts.oauth._middleware(req, new http.ServerResponse(req)); // verify that a user is not created var user = Meteor.users.findOne({"services.failbook.id": failbookId}); test.equal(user, undefined); // verify an error is stored in login state - test.equal(Meteor.accounts.oauth._loginResultForState[state].error, 403); + test.equal(Accounts.oauth._loginResultForState[state].error, 403); // verify error is handed back to login method. test.throws(function () { diff --git a/packages/accounts-password/email_templates.js b/packages/accounts-password/email_templates.js index d5fea9fbd2..d3275b4ed5 100644 --- a/packages/accounts-password/email_templates.js +++ b/packages/accounts-password/email_templates.js @@ -1,10 +1,10 @@ -Meteor.accounts.emailTemplates = { +Accounts.emailTemplates = { from: "Meteor Accounts ", siteName: Meteor.absoluteUrl().replace(/^https?:\/\//, '').replace(/\/$/, ''), resetPassword: { subject: function(user) { - return "How to reset your password on " + Meteor.accounts.emailTemplates.siteName; + return "How to reset your password on " + Accounts.emailTemplates.siteName; }, text: function(user, url) { var greeting = (user.profile && user.profile.name) ? @@ -20,7 +20,7 @@ Meteor.accounts.emailTemplates = { }, validateEmail: { subject: function(user) { - return "How to validate your account email on " + Meteor.accounts.emailTemplates.siteName; + return "How to validate your account email on " + Accounts.emailTemplates.siteName; }, text: function(user, url) { var greeting = (user.profile && user.profile.name) ? @@ -36,7 +36,7 @@ Meteor.accounts.emailTemplates = { }, enrollAccount: { subject: function(user) { - return "An account has been created for you on " + Meteor.accounts.emailTemplates.siteName; + return "An account has been created for you on " + Accounts.emailTemplates.siteName; }, text: function(user, url) { var greeting = (user.profile && user.profile.name) ? diff --git a/packages/accounts-password/email_tests_setup.js b/packages/accounts-password/email_tests_setup.js index e7afd89d7f..c932f62a53 100644 --- a/packages/accounts-password/email_tests_setup.js +++ b/packages/accounts-password/email_tests_setup.js @@ -28,7 +28,7 @@ Meteor.users.update( {_id: this.userId()}, {$push: {emails: {address: email, validated: false}}}); - Meteor.accounts.sendValidationEmail(this.userId(), email); + Accounts.sendValidationEmail(this.userId(), email); }, createUserOnServer: function (email) { diff --git a/packages/accounts-password/passwords_client.js b/packages/accounts-password/passwords_client.js index 83b066042f..ab4f7b09ab 100644 --- a/packages/accounts-password/passwords_client.js +++ b/packages/accounts-password/passwords_client.js @@ -22,7 +22,7 @@ return; } - Meteor.accounts.makeClientLoggedIn(result.id, result.token); + Accounts.makeClientLoggedIn(result.id, result.token); callback && callback(undefined, {message: 'Success'}); }); }; @@ -68,7 +68,7 @@ return; } - Meteor.accounts.makeClientLoggedIn(result.id, result.token); + Accounts.makeClientLoggedIn(result.id, result.token); callback && callback(); }); }); @@ -158,13 +158,13 @@ callback && callback(error); } - Meteor.accounts.makeClientLoggedIn(result.id, result.token); + Accounts.makeClientLoggedIn(result.id, result.token); callback && callback(); }); }; // Validates a user's email address based on a token originally - // created by Meteor.accounts.sendValidationEmail + // created by Accounts.sendValidationEmail // // @param token {String} // @param callback (optional) {Function(error|undefined)} diff --git a/packages/accounts-password/passwords_common.js b/packages/accounts-password/passwords_common.js index 1bf1351dae..69ae38975d 100644 --- a/packages/accounts-password/passwords_common.js +++ b/packages/accounts-password/passwords_common.js @@ -1 +1 @@ -Meteor.accounts.passwords = {}; +Accounts.passwords = {}; diff --git a/packages/accounts-password/passwords_server.js b/packages/accounts-password/passwords_server.js index 2cba4db4e1..e771835dde 100644 --- a/packages/accounts-password/passwords_server.js +++ b/packages/accounts-password/passwords_server.js @@ -1,7 +1,7 @@ (function () { // internal verifier collection. Never published. - Meteor.accounts._srpChallenges = new Meteor.Collection( + Accounts._srpChallenges = new Meteor.Collection( "accounts._srpChallenges", null /*manager*/, null /*driver*/, @@ -11,16 +11,16 @@ // table, and it is _really_ insecure to allow it as users could easily // steal sessions and impersonate other users. Users can override by // calling more allows later, if they really want. - Meteor.accounts._srpChallenges.allow({}); + Accounts._srpChallenges.allow({}); // internal email validation tokens collection. Never published. - Meteor.accounts._emailValidationTokens = new Meteor.Collection( + Accounts._emailValidationTokens = new Meteor.Collection( "accounts._emailValidationTokens", null /*manager*/, null /*driver*/, true /*preventAutopublish*/); // also lock down email validation. These can be used to log in. - Meteor.accounts._emailValidationTokens.allow({}); + Accounts._emailValidationTokens.allow({}); var selectorFromUserQuery = function (user) { @@ -77,7 +77,7 @@ // and then log in as you (but no more insecure than reconnect // tokens). var serialized = { userId: user._id, M: srp.M, HAMK: srp.HAMK }; - Meteor.accounts._srpChallenges.insert(serialized); + Accounts._srpChallenges.insert(serialized); return challenge; }, @@ -94,7 +94,7 @@ } if (options.M) { - var serialized = Meteor.accounts._srpChallenges.findOne( + var serialized = Accounts._srpChallenges.findOne( {M: options.M}); if (!serialized) throw new Meteor.Error(403, "Incorrect password"); @@ -138,12 +138,12 @@ } }}); - var resetPasswordUrl = Meteor.accounts.urls.resetPassword(token); + var resetPasswordUrl = Accounts.urls.resetPassword(token); Email.send({ to: email, - from: Meteor.accounts.emailTemplates.from, - subject: Meteor.accounts.emailTemplates.resetPassword.subject(user), - text: Meteor.accounts.emailTemplates.resetPassword.text(user, resetPasswordUrl)}); + from: Accounts.emailTemplates.from, + subject: Accounts.emailTemplates.resetPassword.subject(user), + text: Accounts.emailTemplates.resetPassword.text(user, resetPasswordUrl)}); }, resetPassword: function (token, newVerifier) { @@ -165,7 +165,7 @@ {$set: {"emails.0.validated": true}}); - var loginToken = Meteor.accounts._loginTokens.insert({userId: user._id}); + var loginToken = Accounts._loginTokens.insert({userId: user._id}); this.setUserId(user._id); return {token: loginToken, id: user._id}; }, @@ -174,7 +174,7 @@ if (!token) throw new Meteor.Error(400, "Need to pass token"); - var tokenDocument = Meteor.accounts._emailValidationTokens.findOne( + var tokenDocument = Accounts._emailValidationTokens.findOne( {token: token}); if (!tokenDocument) throw new Meteor.Error(403, "Validate email link expired"); @@ -186,9 +186,9 @@ // http://www.mongodb.org/display/DOCS/Updating/#Updating-The%24positionaloperator) Meteor.users.update({_id: userId, "emails.address": email}, {$set: {"emails.$.validated": true}}); - Meteor.accounts._emailValidationTokens.remove({token: token}); + Accounts._emailValidationTokens.remove({token: token}); - var loginToken = Meteor.accounts._loginTokens.insert({userId: userId}); + var loginToken = Accounts._loginTokens.insert({userId: userId}); this.setUserId(userId); return {token: loginToken, id: userId}; } @@ -196,10 +196,10 @@ // send the user an email with a link that when opened marks that // address as validated - Meteor.accounts.sendValidationEmail = function (userId, email) { + Accounts.sendValidationEmail = function (userId, email) { var token = Meteor.uuid(); var when = +(new Date); - Meteor.accounts._emailValidationTokens.insert({ + Accounts._emailValidationTokens.insert({ email: email, token: token, when: when, @@ -211,19 +211,19 @@ // this account. var user = Meteor.users.findOne(userId); - var validateEmailUrl = Meteor.accounts.urls.validateEmail(token); + var validateEmailUrl = Accounts.urls.validateEmail(token); Email.send({ to: email, - from: Meteor.accounts.emailTemplates.from, - subject: Meteor.accounts.emailTemplates.validateEmail.subject(user), - text: Meteor.accounts.emailTemplates.validateEmail.text(user, validateEmailUrl) + from: Accounts.emailTemplates.from, + subject: Accounts.emailTemplates.validateEmail.subject(user), + text: Accounts.emailTemplates.validateEmail.text(user, validateEmailUrl) }); }; // send the user an email informing them that their account was // created, with a link that when opened both marks their email as // validated and forces them to choose their password - Meteor.accounts.sendEnrollmentEmail = function (userId, email) { + Accounts.sendEnrollmentEmail = function (userId, email) { var token = Meteor.uuid(); var when = +(new Date); Meteor.users.update(userId, {$set: { @@ -234,29 +234,29 @@ }}); var user = Meteor.users.findOne(userId); - var enrollAccountUrl = Meteor.accounts.urls.enrollAccount(token); + var enrollAccountUrl = Accounts.urls.enrollAccount(token); Email.send({ to: email, - from: Meteor.accounts.emailTemplates.from, - subject: Meteor.accounts.emailTemplates.enrollAccount.subject(user), - text: Meteor.accounts.emailTemplates.enrollAccount.text(user, enrollAccountUrl) + from: Accounts.emailTemplates.from, + subject: Accounts.emailTemplates.enrollAccount.subject(user), + text: Accounts.emailTemplates.enrollAccount.text(user, enrollAccountUrl) }); }; // handler to login with password - Meteor.accounts.registerLoginHandler(function (options) { + Accounts.registerLoginHandler(function (options) { if (!options.srp) return undefined; // don't handle if (!options.srp.M) throw new Meteor.Error(400, "Must pass M in options.srp"); - var serialized = Meteor.accounts._srpChallenges.findOne( + var serialized = Accounts._srpChallenges.findOne( {M: options.srp.M}); if (!serialized) throw new Meteor.Error(403, "Incorrect password"); var userId = serialized.userId; - var loginToken = Meteor.accounts._loginTokens.insert({userId: userId}); + var loginToken = Accounts._loginTokens.insert({userId: userId}); // XXX we should remove srpChallenge documents from mongo, but we // need to make sure reconnects still work (meaning we can't @@ -274,8 +274,8 @@ // over the wire, it should only be run over SSL! // // Also, it might be nice if servers could turn this off. Or maybe it - // should be opt-in, not opt-out? Meteor.accounts.config option? - Meteor.accounts.registerLoginHandler(function (options) { + // should be opt-in, not opt-out? Accounts.config option? + Accounts.registerLoginHandler(function (options) { if (!options.password || !options.user) return undefined; // don't handle @@ -297,7 +297,7 @@ if (verifier.verifier !== newVerifier.verifier) throw new Meteor.Error(403, "Incorrect password"); - var loginToken = Meteor.accounts._loginTokens.insert({userId: user._id}); + var loginToken = Accounts._loginTokens.insert({userId: user._id}); return {token: loginToken, id: user._id}; }); @@ -352,7 +352,7 @@ if (email) user.emails = [{address: email, validated: false}]; - user = Meteor.accounts.onCreateUserHook(options, extra, user); + user = Accounts.onCreateUserHook(options, extra, user); var userId = Meteor.users.insert(user); return userId; }; @@ -360,7 +360,7 @@ // method for create user. Requests come from the client. Meteor.methods({ createUser: function (options, extra) { - if (Meteor.accounts._options.forbidSignups) + if (Accounts._options.forbidSignups) throw new Meteor.Error(403, "Signups forbidden"); var userId = createUser(options, extra); @@ -369,14 +369,14 @@ if (!userId) throw new Error("createUser failed to insert new user"); - // If `Meteor.accounts._options.validateEmails` is set, register + // If `Accounts._options.validateEmails` is set, register // a token to validate the user's primary email, and send it to // that address. - if (options.email && Meteor.accounts._options.validateEmails) - Meteor.accounts.sendValidationEmail(userId, options.email); + if (options.email && Accounts._options.validateEmails) + Accounts.sendValidationEmail(userId, options.email); // client gets logged in as the new user afterwards. - var loginToken = Meteor.accounts._loginTokens.insert({userId: userId}); + var loginToken = Accounts._loginTokens.insert({userId: userId}); this.setUserId(userId); return {token: loginToken, id: userId}; } @@ -413,7 +413,7 @@ user.services.password.srp)) { var email = user.emails[0].address; - Meteor.accounts.sendEnrollmentEmail(userId, email); + Accounts.sendEnrollmentEmail(userId, email); } return userId; diff --git a/packages/accounts-password/passwords_tests.js b/packages/accounts-password/passwords_tests.js index ee8757157d..00a2a4055a 100644 --- a/packages/accounts-password/passwords_tests.js +++ b/packages/accounts-password/passwords_tests.js @@ -95,7 +95,7 @@ if (Meteor.isClient) (function () { test.isTrue(result.id); test.isTrue(result.token); // emulate the real login behavior, so as not to confuse test. - Meteor.accounts.makeClientLoggedIn(result.id, result.token); + Accounts.makeClientLoggedIn(result.id, result.token); test.equal(Meteor.user().username, username); })); }, @@ -137,7 +137,7 @@ if (Meteor.isClient) (function () { test.isTrue(result.id); test.isTrue(result.token); // emulate the real login behavior, so as not to confuse test. - Meteor.accounts.makeClientLoggedIn(result.id, result.token); + Accounts.makeClientLoggedIn(result.id, result.token); test.equal(Meteor.user().username, username2); })); }, @@ -150,7 +150,7 @@ if (Meteor.isClient) (function () { })); }, logoutStep, - // test Meteor.accounts.validateNewUser + // test Accounts.validateNewUser function(test, expect) { Meteor.createUser({username: username3, password: password3}, {invalid: true}, // should fail the new user validators @@ -158,7 +158,7 @@ if (Meteor.isClient) (function () { test.equal(error.error, 403); })); }, - // test Meteor.accounts.onCreateUser + // test Accounts.onCreateUser function(test, expect) { Meteor.createUser({username: username3, password: password3}, {testOnCreateUserHook: true}, expect(function () { @@ -198,7 +198,7 @@ if (Meteor.isServer) (function () { 'passwords - setup more than one onCreateUserHook', function (test) { test.throws(function() { - Meteor.accounts.onCreateUser(function () {}); + Accounts.onCreateUser(function () {}); }); }); @@ -264,5 +264,5 @@ if (Meteor.isServer) (function () { }); }); - // XXX would be nice to test Meteor.accounts.config({forbidSignups: true}) + // XXX would be nice to test Accounts.config({forbidSignups: true}) }) (); diff --git a/packages/accounts-password/passwords_tests_setup.js b/packages/accounts-password/passwords_tests_setup.js index 5ffeae38a6..2b680b98e6 100644 --- a/packages/accounts-password/passwords_tests_setup.js +++ b/packages/accounts-password/passwords_tests_setup.js @@ -1,8 +1,8 @@ -Meteor.accounts.validateNewUser(function (user) { +Accounts.validateNewUser(function (user) { return !user.invalid; }); -Meteor.accounts.onCreateUser(function (options, extra, user) { +Accounts.onCreateUser(function (options, extra, user) { if (extra.testOnCreateUserHook) { user.profile = (user.profile || {}); user.profile.touchedByOnCreateUser = true; @@ -25,7 +25,7 @@ Meteor.accounts.onCreateUser(function (options, extra, user) { // // For now, we just test the one configuration state. You can comment // out each configuration option and see that the tests fail. -Meteor.accounts.config({ +Accounts.config({ validateEmails: true, // The 'accounts - updateOrCreateUser' test needs accounts without // usernames or emails, so we can't test with these on. diff --git a/packages/accounts-twitter/twitter_client.js b/packages/accounts-twitter/twitter_client.js index e21a107452..147a72e79d 100644 --- a/packages/accounts-twitter/twitter_client.js +++ b/packages/accounts-twitter/twitter_client.js @@ -1,8 +1,8 @@ (function () { Meteor.loginWithTwitter = function (callback) { - var config = Meteor.accounts.configuration.findOne({service: 'twitter'}); + var config = Accounts.configuration.findOne({service: 'twitter'}); if (!config) { - callback && callback(new Meteor.accounts.ConfigError("Service not configured")); + callback && callback(new Accounts.ConfigError("Service not configured")); return; } @@ -21,7 +21,7 @@ + encodeURIComponent(callbackUrl) + '&state=' + state; - Meteor.accounts.oauth.initiateLogin(state, url, callback); + Accounts.oauth.initiateLogin(state, url, callback); }; })(); diff --git a/packages/accounts-twitter/twitter_common.js b/packages/accounts-twitter/twitter_common.js index 72d57689fa..3fdcd9d2bc 100644 --- a/packages/accounts-twitter/twitter_common.js +++ b/packages/accounts-twitter/twitter_common.js @@ -1,8 +1,8 @@ -if (!Meteor.accounts.twitter) { - Meteor.accounts.twitter = {}; +if (!Accounts.twitter) { + Accounts.twitter = {}; } -Meteor.accounts.twitter._urls = { +Accounts.twitter._urls = { requestToken: "https://api.twitter.com/oauth/request_token", authorize: "https://api.twitter.com/oauth/authorize", accessToken: "https://api.twitter.com/oauth/access_token", diff --git a/packages/accounts-twitter/twitter_server.js b/packages/accounts-twitter/twitter_server.js index 900331d31b..6bddac2fba 100644 --- a/packages/accounts-twitter/twitter_server.js +++ b/packages/accounts-twitter/twitter_server.js @@ -1,6 +1,6 @@ (function () { - Meteor.accounts.oauth.registerService('twitter', 1, function(oauthBinding) { + Accounts.oauth.registerService('twitter', 1, function(oauthBinding) { var identity = oauthBinding.get('https://api.twitter.com/1/account/verify_credentials.json'); return { diff --git a/packages/accounts-ui-unstyled/login_buttons.js b/packages/accounts-ui-unstyled/login_buttons.js index 23c45781eb..193f99d301 100644 --- a/packages/accounts-ui-unstyled/login_buttons.js +++ b/packages/accounts-ui-unstyled/login_buttons.js @@ -13,7 +13,7 @@ var JUST_VALIDATED_USER_KEY = 'Meteor.loginButtons.justValidatedUser'; var CONFIGURE_LOGIN_SERVICES_DIALOG_VISIBLE = 'Meteor.loginButtons.configureLoginServicesDialogVisible'; var CONFIGURE_LOGIN_SERVICES_DIALOG_SERVICE_NAME = "Meteor.loginButtons.configureLoginServicesDialogServiceName"; - var CONFIGURE_LOGIN_SERVICES_DIALOG_SAVE_ENABLED = "Meteor.accounts.facebook.saveEnabled"; + var CONFIGURE_LOGIN_SERVICES_DIALOG_SAVE_ENABLED = "Accounts.facebook.saveEnabled"; var resetSession = function () { @@ -43,9 +43,9 @@ 'click #login-buttons-Facebook': function () { resetMessages(); Meteor.loginWithFacebook(function (e) { - if (!e || e instanceof Meteor.accounts.LoginCancelledError) { + if (!e || e instanceof Accounts.LoginCancelledError) { // do nothing - } else if (e instanceof Meteor.accounts.ConfigError) { + } else if (e instanceof Accounts.ConfigError) { configureService("Facebook"); // XXX refactor "Facebook" -> "facebook" } else { Session.set(ERROR_MESSAGE_KEY, e.reason || "Unknown error"); @@ -56,9 +56,9 @@ 'click #login-buttons-Google': function () { resetMessages(); Meteor.loginWithGoogle(function (e) { - if (!e || e instanceof Meteor.accounts.LoginCancelledError) { + if (!e || e instanceof Accounts.LoginCancelledError) { // do nothing - } else if (e instanceof Meteor.accounts.ConfigError) { + } else if (e instanceof Accounts.ConfigError) { configureService("Google"); } else { Session.set(ERROR_MESSAGE_KEY, e.reason || "Unknown error"); @@ -69,9 +69,9 @@ 'click #login-buttons-Weibo': function () { resetMessages(); Meteor.loginWithWeibo(function (e) { - if (!e || e instanceof Meteor.accounts.LoginCancelledError) { + if (!e || e instanceof Accounts.LoginCancelledError) { // do nothing - } else if (e instanceof Meteor.accounts.ConfigError) { + } else if (e instanceof Accounts.ConfigError) { configureService("Weibo"); } else { Session.set(ERROR_MESSAGE_KEY, e.reason || "Unknown error"); @@ -82,9 +82,9 @@ 'click #login-buttons-Twitter': function () { resetMessages(); Meteor.loginWithTwitter(function (e) { - if (!e || e instanceof Meteor.accounts.LoginCancelledError) { + if (!e || e instanceof Accounts.LoginCancelledError) { // do nothing - } else if (e instanceof Meteor.accounts.ConfigError) { + } else if (e instanceof Accounts.ConfigError) { configureService("Twitter"); } else { Session.set(ERROR_MESSAGE_KEY, e.reason || "Unknown error"); @@ -115,7 +115,7 @@ }; Template.loginButtons.configurationLoaded = function () { - return Meteor.accounts.loginServicesConfigured(); + return Accounts.loginServicesConfigured(); }; Template.loginButtons.displayName = function () { @@ -211,17 +211,17 @@ var loginFields = [ {fieldName: 'username-or-email', fieldLabel: 'Username or Email', visible: function () { - return Meteor.accounts._options.requireUsername - && Meteor.accounts._options.requireEmail; + return Accounts._options.requireUsername + && Accounts._options.requireEmail; }}, {fieldName: 'username', fieldLabel: 'Username', visible: function () { - return Meteor.accounts._options.requireUsername - && !Meteor.accounts._options.requireEmail; + return Accounts._options.requireUsername + && !Accounts._options.requireEmail; }}, {fieldName: 'email', fieldLabel: 'Email', visible: function () { - return !Meteor.accounts._options.requireUsername; + return !Accounts._options.requireUsername; }}, {fieldName: 'password', fieldLabel: 'Password', inputType: 'password', visible: function () { @@ -232,12 +232,12 @@ var signupFields = [ {fieldName: 'username', fieldLabel: 'Username', visible: function () { - return Meteor.accounts._options.requireUsername; + return Accounts._options.requireUsername; }}, {fieldName: 'email', fieldLabel: 'Email', visible: function () { - return !Meteor.accounts._options.requireUsername - || Meteor.accounts._options.requireEmail; + return !Accounts._options.requireUsername + || Accounts._options.requireEmail; }}, {fieldName: 'password', fieldLabel: 'Password', inputType: 'password', visible: function () { @@ -246,8 +246,8 @@ {fieldName: 'password-again', fieldLabel: 'Password (again)', inputType: 'password', visible: function () { - return Meteor.accounts._options.requireUsername - && !Meteor.accounts._options.requireEmail; + return Accounts._options.requireUsername + && !Accounts._options.requireEmail; }} ]; @@ -282,12 +282,12 @@ }; Template.loginButtonsServicesRow.showForgotPasswordLink = function () { - return Meteor.accounts._options.requireEmail - || !Meteor.accounts._options.requireUsername; + return Accounts._options.requireEmail + || !Accounts._options.requireUsername; }; Template.loginButtonsServicesRow.configured = function () { - return !!Meteor.accounts.configuration.findOne({service: this.name.toLowerCase()}); + return !!Accounts.configuration.findOne({service: this.name.toLowerCase()}); }; @@ -381,7 +381,7 @@ }, 'click #login-buttons-cancel-reset-password': function () { Session.set(RESET_PASSWORD_TOKEN_KEY, null); - Meteor.accounts._enableAutoLogin(); + Accounts._enableAutoLogin(); } }; @@ -398,7 +398,7 @@ Session.set(ERROR_MESSAGE_KEY, error.reason || "Unknown error"); } else { Session.set(RESET_PASSWORD_TOKEN_KEY, null); - Meteor.accounts._enableAutoLogin(); + Accounts._enableAutoLogin(); } }); }; @@ -407,8 +407,8 @@ return Session.get(RESET_PASSWORD_TOKEN_KEY); }; - if (Meteor.accounts._resetPasswordToken) { - Session.set(RESET_PASSWORD_TOKEN_KEY, Meteor.accounts._resetPasswordToken); + if (Accounts._resetPasswordToken) { + Session.set(RESET_PASSWORD_TOKEN_KEY, Accounts._resetPasswordToken); } @@ -426,7 +426,7 @@ }, 'click #login-buttons-cancel-enroll-account': function () { Session.set(ENROLL_ACCOUNT_TOKEN_KEY, null); - Meteor.accounts._enableAutoLogin(); + Accounts._enableAutoLogin(); } }; @@ -443,7 +443,7 @@ Session.set(ERROR_MESSAGE_KEY, error.reason || "Unknown error"); } else { Session.set(ENROLL_ACCOUNT_TOKEN_KEY, null); - Meteor.accounts._enableAutoLogin(); + Accounts._enableAutoLogin(); } }); }; @@ -452,8 +452,8 @@ return Session.get(ENROLL_ACCOUNT_TOKEN_KEY); }; - if (Meteor.accounts._enrollAccountToken) { - Session.set(ENROLL_ACCOUNT_TOKEN_KEY, Meteor.accounts._enrollAccountToken); + if (Accounts._enrollAccountToken) { + Session.set(ENROLL_ACCOUNT_TOKEN_KEY, Accounts._enrollAccountToken); } @@ -476,9 +476,9 @@ // issue. We can't be sure that accounts-password is loaded earlier // than accounts-ui so Meteor.validateEmail might not be defined. Meteor.startup(function () { - if (Meteor.accounts._validateEmailToken) { - Meteor.validateEmail(Meteor.accounts._validateEmailToken, function(error) { - Meteor.accounts._enableAutoLogin(); + if (Accounts._validateEmailToken) { + Meteor.validateEmail(Accounts._validateEmailToken, function(error) { + Accounts._enableAutoLogin(); if (!error) Session.set(JUST_VALIDATED_USER_KEY, true); // XXX show something if there was an error. @@ -645,7 +645,7 @@ } } - if (Meteor.accounts._options.validateEmails) + if (Accounts._options.validateEmails) options.validation = true; Meteor.createUser(options, function (error) { @@ -665,19 +665,19 @@ var getLoginServices = function () { var ret = []; // XXX It would be nice if there were an automated way to read the - // list of services, such as _.each(Meteor.accounts.services, ...) - if (Meteor.accounts.facebook) + // list of services, such as _.each(Accounts.services, ...) + if (Accounts.facebook) ret.push({name: 'Facebook'}); - if (Meteor.accounts.google) + if (Accounts.google) ret.push({name: 'Google'}); - if (Meteor.accounts.weibo) + if (Accounts.weibo) ret.push({name: 'Weibo'}); - if (Meteor.accounts.twitter) + if (Accounts.twitter) ret.push({name: 'Twitter'}); // make sure to put accounts last, since this is the order in the // ui as well - if (Meteor.accounts.passwords) + if (Accounts.passwords) ret.push({name: 'Password'}); return ret; diff --git a/packages/accounts-urls/url_client.js b/packages/accounts-urls/url_client.js index dda6b80f2f..47add8934d 100644 --- a/packages/accounts-urls/url_client.js +++ b/packages/accounts-urls/url_client.js @@ -1,6 +1,6 @@ (function () { - if (!Meteor.accounts) - Meteor.accounts = {}; + if (!Accounts) + Accounts = {}; // reads a reset password token from the url's hash fragment, if it's // there. if so prevent automatically logging in since it could be @@ -13,8 +13,8 @@ var match; match = window.location.hash.match(/^\#\?reset-password\/(.*)$/); if (match) { - Meteor.accounts._preventAutoLogin = true; - Meteor.accounts._resetPasswordToken = match[1]; + Accounts._preventAutoLogin = true; + Accounts._resetPasswordToken = match[1]; window.location.hash = ''; } @@ -30,8 +30,8 @@ // in line with the hash fragment approach) match = window.location.hash.match(/^\#\?validate-email\/(.*)$/); if (match) { - Meteor.accounts._preventAutoLogin = true; - Meteor.accounts._validateEmailToken = match[1]; + Accounts._preventAutoLogin = true; + Accounts._validateEmailToken = match[1]; window.location.hash = ''; } @@ -40,8 +40,8 @@ // reset password links. match = window.location.hash.match(/^\#\?enroll-account\/(.*)$/); if (match) { - Meteor.accounts._preventAutoLogin = true; - Meteor.accounts._enrollAccountToken = match[1]; + Accounts._preventAutoLogin = true; + Accounts._enrollAccountToken = match[1]; window.location.hash = ''; } })(); diff --git a/packages/accounts-urls/url_server.js b/packages/accounts-urls/url_server.js index 2b8e991a58..cf82b12375 100644 --- a/packages/accounts-urls/url_server.js +++ b/packages/accounts-urls/url_server.js @@ -1,17 +1,17 @@ -if (!Meteor.accounts) - Meteor.accounts = {}; +if (!Accounts) + Accounts = {}; -if (!Meteor.accounts.urls) - Meteor.accounts.urls = {}; +if (!Accounts.urls) + Accounts.urls = {}; -Meteor.accounts.urls.resetPassword = function (token) { +Accounts.urls.resetPassword = function (token) { return Meteor.absoluteUrl('#?reset-password/' + token); }; -Meteor.accounts.urls.validateEmail = function (token) { +Accounts.urls.validateEmail = function (token) { return Meteor.absoluteUrl('#?validate-email/' + token); }; -Meteor.accounts.urls.enrollAccount = function (token) { +Accounts.urls.enrollAccount = function (token) { return Meteor.absoluteUrl('#?enroll-account/' + token); }; diff --git a/packages/accounts-weibo/weibo_client.js b/packages/accounts-weibo/weibo_client.js index 9cc2bfaf94..e119a13e9f 100644 --- a/packages/accounts-weibo/weibo_client.js +++ b/packages/accounts-weibo/weibo_client.js @@ -1,8 +1,8 @@ (function () { Meteor.loginWithWeibo = function (callback) { - var config = Meteor.accounts.configuration.findOne({service: 'weibo'}); + var config = Accounts.configuration.findOne({service: 'weibo'}); if (!config) { - callback && callback(new Meteor.accounts.ConfigError("Service not configured")); + callback && callback(new Accounts.ConfigError("Service not configured")); return; } @@ -15,7 +15,7 @@ '&redirect_uri=' + Meteor.absoluteUrl('_oauth/weibo?close', {replaceLocalhost: true}) + '&state=' + state; - Meteor.accounts.oauth.initiateLogin(state, loginUrl, callback); + Accounts.oauth.initiateLogin(state, loginUrl, callback); }; }) (); diff --git a/packages/accounts-weibo/weibo_common.js b/packages/accounts-weibo/weibo_common.js index 9f9d3f0692..c655866943 100644 --- a/packages/accounts-weibo/weibo_common.js +++ b/packages/accounts-weibo/weibo_common.js @@ -1,9 +1,9 @@ -if (!Meteor.accounts.weibo) { - Meteor.accounts.weibo = {}; - Meteor.accounts.weibo._requireConfigs = ['_clientId', '_appUrl']; +if (!Accounts.weibo) { + Accounts.weibo = {}; + Accounts.weibo._requireConfigs = ['_clientId', '_appUrl']; } -Meteor.accounts.weibo.config = function(clientId, appUrl) { - Meteor.accounts.weibo._clientId = clientId; - Meteor.accounts.weibo._appUrl = appUrl; +Accounts.weibo.config = function(clientId, appUrl) { + Accounts.weibo._clientId = clientId; + Accounts.weibo._appUrl = appUrl; }; diff --git a/packages/accounts-weibo/weibo_server.js b/packages/accounts-weibo/weibo_server.js index 1c95214001..c8d8e8b882 100644 --- a/packages/accounts-weibo/weibo_server.js +++ b/packages/accounts-weibo/weibo_server.js @@ -1,6 +1,6 @@ (function () { - Meteor.accounts.oauth.registerService('weibo', 2, function(query) { + Accounts.oauth.registerService('weibo', 2, function(query) { var accessToken = getAccessToken(query); var identity = getIdentity(accessToken.access_token, parseInt(accessToken.uid, 10)); @@ -20,9 +20,9 @@ }); var getAccessToken = function (query) { - var config = Meteor.accounts.configuration.findOne({service: 'weibo'}); + var config = Accounts.configuration.findOne({service: 'weibo'}); if (!config) - throw new Meteor.accounts.ConfigError("Service not configured"); + throw new Accounts.ConfigError("Service not configured"); var result = Meteor.http.post( "https://api.weibo.com/oauth2/access_token", {params: {