Prepend '_' to internal things in Accounts.

find . -name '*.js' -print0 | xargs -0 perl -pi -e 's/makeClientLoggedIn/_makeClientLoggedIn/g'
find . -name '*.js' -print0 | xargs -0 perl -pi -e 's/makeClientLoggedOut/_makeClientLoggedOut/g'
find . -name '*.js' -print0 | xargs -0 perl -pi -e 's/storeLoginToken/_storeLoginToken/g'
find . -name '*.js' -print0 | xargs -0 perl -pi -e 's/storedLoginToken/_storedLoginToken/g'
find . -name '*.js' -print0 | xargs -0 perl -pi -e 's/unstoreLoginToken/_unstoreLoginToken/g'
find . -name '*.js' -print0 | xargs -0 perl -pi -e 's/storedUserId/_storedUserId/g'
find . -name '*.js' -print0 | xargs -0 perl -pi -e 's/un_storeLoginToken/_unstoreLoginToken/g'
This commit is contained in:
Nick Martin
2012-10-01 15:44:14 -07:00
parent 75c69301c0
commit 9392fbb51d
5 changed files with 21 additions and 21 deletions

View File

@@ -26,7 +26,7 @@
if (error) {
callback && callback(error);
} else {
Accounts.makeClientLoggedOut();
Accounts._makeClientLoggedOut();
callback && callback();
}
});

View File

@@ -3,7 +3,7 @@
var loginTokenKey = "Meteor.loginToken";
var userIdKey = "Meteor.userId";
Accounts.storeLoginToken = function(userId, token) {
Accounts._storeLoginToken = function(userId, token) {
localStorage.setItem(userIdKey, userId);
localStorage.setItem(loginTokenKey, token);
@@ -12,7 +12,7 @@
Accounts._lastLoginTokenWhenPolled = token;
};
Accounts.unstoreLoginToken = function() {
Accounts._unstoreLoginToken = function() {
localStorage.removeItem(userIdKey);
localStorage.removeItem(loginTokenKey);
@@ -21,27 +21,27 @@
Accounts._lastLoginTokenWhenPolled = null;
};
Accounts.storedLoginToken = function() {
Accounts._storedLoginToken = function() {
return localStorage.getItem(loginTokenKey);
};
Accounts.storedUserId = function() {
Accounts._storedUserId = function() {
return localStorage.getItem(userIdKey);
};
Accounts.makeClientLoggedOut = function() {
Accounts.unstoreLoginToken();
Accounts._makeClientLoggedOut = function() {
Accounts._unstoreLoginToken();
Meteor.default_connection.setUserId(null);
Meteor.default_connection.onReconnect = null;
};
Accounts.makeClientLoggedIn = function(userId, token) {
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) {
Accounts.makeClientLoggedOut();
Accounts._makeClientLoggedOut();
throw error;
} else {
// nothing to do
@@ -62,21 +62,21 @@ Meteor.loginWithToken = function (token, errorCallback) {
throw error;
}
Accounts.makeClientLoggedIn(result.id, result.token);
Accounts._makeClientLoggedIn(result.id, result.token);
});
};
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 = 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 = Accounts.storedUserId();
var userId = Accounts._storedUserId();
userId && Meteor.default_connection.setUserId(userId);
Meteor.loginWithToken(token, function () {
Accounts.makeClientLoggedOut();
Accounts._makeClientLoggedOut();
});
}
}
@@ -88,7 +88,7 @@ Accounts._pollStoredLoginToken = function() {
if (Accounts._preventAutoLogin)
return;
var currentLoginToken = Accounts.storedLoginToken();
var currentLoginToken = Accounts._storedLoginToken();
// != instead of !== just to make sure undefined and null are treated the same
if (Accounts._lastLoginTokenWhenPolled != currentLoginToken) {

View File

@@ -47,7 +47,7 @@
callback &&
callback(new Accounts.LoginCancelledError("Popup closed"));
} else {
Accounts.makeClientLoggedIn(result.id, result.token);
Accounts._makeClientLoggedIn(result.id, result.token);
callback && callback();
}
});

View File

@@ -22,7 +22,7 @@
return;
}
Accounts.makeClientLoggedIn(result.id, result.token);
Accounts._makeClientLoggedIn(result.id, result.token);
callback && callback(undefined, {message: 'Success'});
});
};
@@ -68,7 +68,7 @@
return;
}
Accounts.makeClientLoggedIn(result.id, result.token);
Accounts._makeClientLoggedIn(result.id, result.token);
callback && callback();
});
});
@@ -158,7 +158,7 @@
callback && callback(error);
}
Accounts.makeClientLoggedIn(result.id, result.token);
Accounts._makeClientLoggedIn(result.id, result.token);
callback && callback();
});
};

View File

@@ -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.
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.
Accounts.makeClientLoggedIn(result.id, result.token);
Accounts._makeClientLoggedIn(result.id, result.token);
test.equal(Meteor.user().username, username2);
}));
},