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/logout.coffee

35 lines
735 B
CoffeeScript
Raw Normal View History

2019-05-09 12:32:28 +00:00
logger = (require 'logging').default '/user/logout'
2019-05-07 20:15:18 +00:00
# session storage (volatile data)
session = (require '../../session')
module.exports =
url: '/user/logout'
method: 'POST'
2019-05-07 20:33:37 +00:00
schema:
body:
session: type: 'string'
response:
200:
type: 'object'
required: ['success']
properties:
success:
type: 'boolean'
const: true
2019-05-07 20:15:18 +00:00
handler: (request, reply) ->
new Promise (resolve) ->
session.destroy request.body.session ? ""
.then ->
# active session found
logger.debug "OK removed session '#{request.body.session}'"
resolve null
.catch ->
resolve null
.then ->
reply.send
success: true