mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-28 01:55:38 -05:00
Merge pull request #2339 from amankr/server
Added user info to db error
This commit is contained in:
commit
d0f661508c
2 changed files with 9 additions and 0 deletions
|
@ -43,6 +43,9 @@ module.exports.setup = (app) ->
|
|||
handler[req.route.method](req, res, parts[1..]...)
|
||||
catch error
|
||||
errorMessage = "Error trying db method #{req?.route?.method} route #{parts} from #{name}: #{error}"
|
||||
if req.user?
|
||||
userInfo = req.user.getUserInfo()
|
||||
errorMessage += "\n-- User Info Id: #{userInfo.id} #{if req.user.isAnonymous() then '' else 'Email:'} #{userInfo.email}"
|
||||
log.error(errorMessage)
|
||||
log.error(error)
|
||||
log.error(error.stack)
|
||||
|
|
|
@ -45,6 +45,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