added me to event context

This commit is contained in:
Ritchie Martori
2012-06-18 16:21:39 -07:00
parent 98d4d2bf3f
commit 2d8130db3d
3 changed files with 6 additions and 3 deletions

View File

@@ -185,13 +185,13 @@ Collection.prototype.parseId = function(ctx) {
*/
Collection.prototype.execListener = function(method, session, query, item, client, fn) {
var listener = this.settings && this.settings['on' + method]
, errors
, data = item
, options = {
this: item,
context: {
me: session && session.user,
internal: session.internal,
console: console,
emit: function(collection, query, event, data) {
@@ -241,6 +241,9 @@ Collection.prototype.execListener = function(method, session, query, item, clien
var opts = {
this: item,
context: {
me: session && session.user,
query: query,
session: session,
internal: session.internal,
console: console,
emit: options.context.emit,

View File

@@ -143,7 +143,7 @@ UserCollection.prototype.handleSession = function (ctx, fn) {
, path = this.settings.path;
if(session && session.data.path == path && session.data.uid) {
this.store.find({id: session.data.uid}, function(err, user) {
this.store.find({id: session.data.uid, $fields: {password: 0}}, function(err, user) {
session.user = user;
fn(err);
});

View File

@@ -48,7 +48,7 @@ Router.prototype.route = function (req, res) {
this.resources.forEach(function(resource) {
var ctx = new Context(resource, req, res, server);
// BUG - not calling back
// if(resource.handleSession) resource.handleSession(ctx, next());
if(resource.handleSession) resource.handleSession(ctx, next());
})
//TODO: Handle edge case where next() is called more than once