34 lines
895 B
CoffeeScript
34 lines
895 B
CoffeeScript
logger = (require 'logging').default '/user/info'
|
|
|
|
# session storage (volatile data)
|
|
session = (require '../../session')
|
|
# fftcg.db (persistent data)
|
|
fftcgdb = (require '../../db')
|
|
|
|
module.exports =
|
|
url: '/user/info'
|
|
method: 'POST'
|
|
schema: (require './info.schema')
|
|
|
|
handler: (request, reply) ->
|
|
session.check request.body.session ? ""
|
|
.then (userid) ->
|
|
# active session found, get associated user
|
|
fftcgdb.get (userid)
|
|
.then (user) ->
|
|
logger.debug "OK '#{user.login}' got info"
|
|
reply.send
|
|
success: true
|
|
user: user
|
|
|
|
.catch (err) ->
|
|
# couldnt get user details
|
|
logger.warn "FAIL '#{err}' for user id '#{userid}'"
|
|
reply.send
|
|
success: false
|
|
|
|
.catch ->
|
|
# no session found
|
|
logger.info "FAIL '#{request.body.session}' session not found"
|
|
reply.send
|
|
success: false
|