This repository has been archived on 2024-04-29. You can view files and clone it, but cannot push or open issues or pull requests.
node-fftcg/backend/routes/user/info.coffee

35 lines
895 B
CoffeeScript
Raw Normal View History

2019-05-09 12:32:28 +00:00
logger = (require 'logging').default '/user/info'
2019-05-09 12:31:54 +00:00
# session storage (volatile data)
session = (require '../../session')
# fftcg.db (persistent data)
fftcgdb = (require '../../db')
2019-05-09 12:31:54 +00:00
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
2019-05-09 12:31:54 +00:00
.catch ->
# no session found
logger.info "FAIL '#{request.body.session}' session not found"
reply.send
success: false