logger = (require 'logging').default '/user/logout'
# session storage (volatile data)
session = (require '../../session')
module.exports =
url: '/user/logout'
method: 'POST'
schema: (require './logout.schema')
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 ->
reply.send
success: true