'use strict' const Joi = require('joi') const params = require('../../schemas/params') const pluginConfig = { handlerType: 'password', docs: { get: { description: 'get password', notes: 'Returns a password by the user email passed in the path', }, }, } /** Validator functions by request method */ const validators = { /** Validate the route params (/active/{thing}) */ params: params.userEmail } module.exports = { method: 'GET', path: '/{user_email}/password', options: { ...pluginConfig.docs.get, tags: ['api'], // auth: 'default_jwt', auth: false, cors: true, handler: async function (request, h) { try { const { userService } = request.services() const userEmail = request.params.user_email const password = await userService.getPassword(userEmail) return { ok: true, handler: pluginConfig.handlerType, data: { password: password }, } } catch (err) { return { ok: false, handler: pluginConfig.handlerType, data: { error: err }, } } }, validate: { ...validators, failAction: 'log', }, response: { schema: Joi.object({ ok: Joi.bool(), handler: Joi.string(), data: Joi.object(), }).label('password_res'), failAction: 'log', }, }, }