mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 23:58:02 -05:00
Added user info to db error
This commit is contained in:
parent
85a024546b
commit
c76241be40
2 changed files with 9 additions and 0 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue