mirror of
https://github.com/zhigang1992/deployd.git
synced 2026-05-26 00:21:42 +08:00
added me to event context
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user