diff --git a/server/routes/db.coffee b/server/routes/db.coffee index 8bcc8e231..fa281377a 100644 --- a/server/routes/db.coffee +++ b/server/routes/db.coffee @@ -42,6 +42,9 @@ module.exports.setup = (app) -> return handler.patch(req, res, parts[1]) if req.route.method is 'patch' and parts[1]? handler[req.route.method](req, res, parts[1..]...) catch error + if req.user? + userInfo = req.user.getUserInfo() + log.info("UserId: #{userInfo.id} #{if req.user.isAnonymous() then '' else 'Email:'} #{userInfo.email}") errorMessage = "Error trying db method #{req?.route?.method} route #{parts} from #{name}: #{error}" log.error(errorMessage) log.error(error) diff --git a/server/users/User.coffee b/server/users/User.coffee index 61596c6f5..92445b4d0 100644 --- a/server/users/User.coffee +++ b/server/users/User.coffee @@ -41,6 +41,12 @@ UserSchema.methods.isAdmin = -> UserSchema.methods.isAnonymous = -> @get 'anonymous' +UserSchema.methods.getUserInfo = -> + info = + id : @get('_id') + email : if @get('anonymous') then 'Unregistered User' else @get('email') + return info + UserSchema.methods.trackActivity = (activityName, increment) -> now = new Date() increment ?= parseInt increment or 1