34 lines
735 B
CoffeeScript
34 lines
735 B
CoffeeScript
logger = (require 'logging').default '/user/logout'
|
|
|
|
# session storage (volatile data)
|
|
session = (require '../../session')
|
|
|
|
module.exports =
|
|
url: '/user/logout'
|
|
method: 'POST'
|
|
schema:
|
|
body:
|
|
session: type: 'string'
|
|
response:
|
|
200:
|
|
type: 'object'
|
|
required: ['success']
|
|
properties:
|
|
success:
|
|
type: 'boolean'
|
|
const: true
|
|
|
|
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
|