mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
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:
@@ -26,7 +26,7 @@
|
||||
if (error) {
|
||||
callback && callback(error);
|
||||
} else {
|
||||
Accounts.makeClientLoggedOut();
|
||||
Accounts._makeClientLoggedOut();
|
||||
callback && callback();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
}));
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user