Ah I see.
Meteor.user()
calls Accounts.user()
which is found here:
Meteor.userId()
calls Accounts.userId()
which is found here:
Accounts.user()
is implemented here:
* @locus Anywhere
*/
userId() {
throw new Error("userId method not implemented");
}
/**
* @summary Get the current user record, or `null` if no user is logged in. A reactive data source.
* @locus Anywhere
*/
user() {
var userId = this.userId();
return userId ? this.users.findOne(userId) : null;
}
// Set up config for the accounts system. Call this on both the client
// and the server.
//
// Note that this method gets overridden on AccountsServer.prototype, but
// the overriding method calls the overridden method.
//
Accounts.userId()
is implemented here:
this._onLogoutHook = new Hook({
bindEnvironment: false,
debugPrintExceptions: "onLogout callback"
});
}
/**
* @summary Get the current user id, or `null` if no user is logged in. A reactive data source.
* @locus Anywhere
*/
userId() {
throw new Error("userId method not implemented");
}
/**
* @summary Get the current user record, or `null` if no user is logged in. A reactive data source.
* @locus Anywhere
*/
user() {
var userId = this.userId();
return userId ? this.users.findOne(userId) : null;
this.userId
for methods is implemented here:
*/
this.isSimulation = options.isSimulation;
// call this function to allow other method invocations (from the
// same client) to continue running without waiting for this one to
// complete.
this._unblock = options.unblock || function () {};
this._calledUnblock = false;
// current user id
/**
* @summary The id of the user that made this method call, or `null` if no user was logged in.
* @locus Anywhere
* @name userId
* @memberOf DDPCommon.MethodInvocation
* @instance
*/
this.userId = options.userId;
// sets current user id in all appropriate server contexts and
this.userId
for publications is implemented here:
// Only named subscriptions have IDs, but we need some sort of string
// internally to keep track of all subscriptions inside
// SessionDocumentViews. We use this subscriptionHandle for that.
if (self._subscriptionId) {
self._subscriptionHandle = 'N' + self._subscriptionId;
} else {
self._subscriptionHandle = 'U' + Random.id();
}
// has _deactivate been called?
self._deactivated = false;
// stop callbacks to g/c this sub. called w/ zero arguments.
self._stopCallbacks = [];
// the set of (collection, documentid) that this subscription has
// an opinion about
self._documents = {};
// remember if we are ready.
this
with regards to a publication is a Subscription
object which is implemented here:
// the original IP address of the client connecting to the first
// proxy. However, the end user can easily spoof the header, in
// which case the first value(s) will be the fake IP address from
// the user pretending to be a proxy reporting the original IP
// address value. By counting HTTP_FORWARDED_COUNT back from the
// end of the list, we ensure that we get the IP address being
// reported by *our* first proxy.
if (httpForwardedCount < 0 || httpForwardedCount > forwardedFor.length)
return null;
return forwardedFor[forwardedFor.length - httpForwardedCount];
}
});
/******************************************************************************/
/* Subscription */
/******************************************************************************/
// ctor for a sub handle: the input to each publish function
this
with regards to a method is a DDPCommon.MethodInvocation
which is implemented here:
// Instance name is this because it is usually referred to as this inside a
// method definition
/**
* @summary The state for a single invocation of a method, referenced by this
* inside a method definition.
* @param {Object} options
* @instanceName this
* @showInstanceName true
*/
DDPCommon.MethodInvocation = function (options) {
var self = this;
// true if we're running not the actual method, but a stub (that is,
// if we're on a client (which may be a browser, or in the future a
// server connecting to another server) and presently running a
// simulation of a server-side method for latency compensation
// purposes). not currently true except in a client such as a browser,
// since there's usually no point in running stubs unless you have a
// zero-latency connection to the user.