Compare commits

1 Commits

Author SHA1 Message Date
Mike Fitzpatrick
1936683f0e - Fixes for missing signup imports 2019-08-17 02:47:31 -04:00
4 changed files with 11 additions and 8 deletions

View File

@@ -1,3 +1,5 @@
const errors = require('restify-errors');
const validateJsonData = (req, res, next) => { const validateJsonData = (req, res, next) => {
if (!req.is('application/json')) { if (!req.is('application/json')) {
return next( return next(

View File

@@ -15,7 +15,7 @@ const PhoneSchema = new mongoose.Schema(
label: { label: {
type: String, type: String,
required: true, required: true,
enum: [ 'home', 'mobile' ], enum: [ 'home', 'mobile', 'work' ],
}, },
}, },

View File

@@ -7,5 +7,6 @@ module.exports = function(server, auth) {
require('./items.js')(server, auth); require('./items.js')(server, auth);
require('./reset.js')(server, auth); require('./reset.js')(server, auth);
require('./sales.js')(server, auth); require('./sales.js')(server, auth);
require('./signup.js')(server, auth);
require('./users.js')(server, auth); require('./users.js')(server, auth);
}; };

View File

@@ -5,13 +5,13 @@ const User = require('../models/user');
module.exports = function (server, auth) { module.exports = function (server, auth) {
const { passport } = auth; const { passport } = auth;
server.post('/signup', (req, res, next) => { server.post('/signup', auth.basic, (req, res, next) => {
const { body: { user = null } = {} } = req; const { body: { user = null } = {} } = req;
let errors = {}; let errors = {};
let errorCount = 0; let errorCount = 0;
if (!user) { if (!user) {
errors.user = 'is required - can\'t make something from nothing...''; errors.user = 'is required - can\'t make something from nothing...';
errorCount++; errorCount++;
} }
@@ -27,7 +27,7 @@ module.exports = function (server, auth) {
if (info) { if (info) {
res.send(200, { res.send(200, {
success: false, success: false,
nextSteps: 'Please fix the problems indicated and try again.' nextSteps: 'Please fix the problems indicated and try again.',
...info ...info
}); });
@@ -36,14 +36,14 @@ module.exports = function (server, auth) {
res.send(200, { res.send(200, {
success: true, 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(); 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); const email = decodeURI(req.params.email);
User.findOne({ email }, (err, user) => { 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); const nomDeBid = decodeURI(req.params.nom_de_bid);
User.findOne({ nomDeBid }, (err, user) => { 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; const { body: { email = null } = {} } = req;
User.resendVerificationEmail(email, (err, user, info) => { User.resendVerificationEmail(email, (err, user, info) => {