Advertisement
Guest User

Untitled

a guest
Oct 25th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'use strict'
  2. /**
  3.  * Route definition for authentication/authorization endpoints.
  4.  * @author Challenge.IT
  5.  */
  6. const Boom = require('boom')
  7. const Joi = require('joi')
  8.  
  9. module.exports = (server, opts) => {
  10.  
  11.     server.route({
  12.         method: 'POST',
  13.         path: '/login',
  14.         handler: function(request, reply) {
  15.             opts.customProvider.login(request.payload.username, request.payload.password, (err, user) => {
  16.                 reply(err? (err.code? Boom.badRequest(err.message) : err) : null, {user: user})
  17.             })
  18.         },
  19.         config: {
  20.             auth: false,
  21.             validate: {
  22.                 payload: {
  23.                     username: Joi.string().required(),
  24.                     password: Joi.string().required()
  25.                 }
  26.             }
  27.         }
  28.     })
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement