From 1936683f0efeaeb9e7c1dc017d3d66fcf1c90b8c Mon Sep 17 00:00:00 2001 From: Mike Fitzpatrick Date: Sat, 17 Aug 2019 02:47:31 -0400 Subject: [PATCH] - Fixes for missing signup imports --- lib/validateType.js | 2 ++ models/common/phone.js | 2 +- routes/index.js | 1 + routes/signup.js | 14 +++++++------- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/validateType.js b/lib/validateType.js index a0dc560..b35943a 100644 --- a/lib/validateType.js +++ b/lib/validateType.js @@ -1,3 +1,5 @@ +const errors = require('restify-errors'); + const validateJsonData = (req, res, next) => { if (!req.is('application/json')) { return next( diff --git a/models/common/phone.js b/models/common/phone.js index 11b9d5e..1864a15 100644 --- a/models/common/phone.js +++ b/models/common/phone.js @@ -15,7 +15,7 @@ const PhoneSchema = new mongoose.Schema( label: { type: String, required: true, - enum: [ 'home', 'mobile' ], + enum: [ 'home', 'mobile', 'work' ], }, }, diff --git a/routes/index.js b/routes/index.js index b62f701..2963c7d 100644 --- a/routes/index.js +++ b/routes/index.js @@ -7,5 +7,6 @@ module.exports = function(server, auth) { require('./items.js')(server, auth); require('./reset.js')(server, auth); require('./sales.js')(server, auth); + require('./signup.js')(server, auth); require('./users.js')(server, auth); }; diff --git a/routes/signup.js b/routes/signup.js index b993054..60ba19a 100644 --- a/routes/signup.js +++ b/routes/signup.js @@ -5,13 +5,13 @@ const User = require('../models/user'); module.exports = function (server, auth) { const { passport } = auth; - server.post('/signup', (req, res, next) => { + server.post('/signup', auth.basic, (req, res, next) => { const { body: { user = null } = {} } = req; let errors = {}; let errorCount = 0; if (!user) { - errors.user = 'is required - can\'t make something from nothing...''; + errors.user = 'is required - can\'t make something from nothing...'; errorCount++; } @@ -27,7 +27,7 @@ module.exports = function (server, auth) { if (info) { res.send(200, { success: false, - nextSteps: 'Please fix the problems indicated and try again.' + nextSteps: 'Please fix the problems indicated and try again.', ...info }); @@ -36,14 +36,14 @@ module.exports = function (server, auth) { res.send(200, { success: true, - nextSteps: 'Check your email for our confirmation email, you will not be able to login without confirming.' + nextSteps: 'Check your email for our confirmation email, you will not be able to login without confirming.', }); next(); }); }); - server.get('/signup/validate/email/:email', (req, res, next) => { + server.get('/signup/validate/email/:email', auth.basic, (req, res, next) => { const email = decodeURI(req.params.email); User.findOne({ email }, (err, user) => { @@ -56,7 +56,7 @@ module.exports = function (server, auth) { }); }); - server.get('/signup/validate/nom/:nom_de_bid', (req, res, next) => { + server.get('/signup/validate/nom/:nom_de_bid', auth.basic, (req, res, next) => { const nomDeBid = decodeURI(req.params.nom_de_bid); User.findOne({ nomDeBid }, (err, user) => { @@ -69,7 +69,7 @@ module.exports = function (server, auth) { }); }); - server.post('/signup/verify/resend', (req, res, next) => { + server.post('/signup/verify/resend', auth.basic, (req, res, next) => { const { body: { email = null } = {} } = req; User.resendVerificationEmail(email, (err, user, info) => {