My goal is simple. If a user is attempting to register and clicks "submit" before all required fields are full, I want to redirect him or her back to the registration page, but change it slightly so that a red asterisk appears next to each required field (this is an arbitrary and ugly choice, I know). I imagine I don't have to have a separate view just for this purpose. Is it possible to alter the registration view in this way?
In routes.js
// process the signup form
app.post('/signup', passport.authenticate('local-signup', {
successRedirect : '/profile', // redirect to the secure profile section
failureRedirect : '/signup?missingFields=true', // redirect back to the signup page if there is an error
failureFlash : true // allow flash messages
}));
In signup.ejs
% if (req.params.missingFields) {%>
BLAH
<% } %>
I get an error in signup.ejs "req is not defined at eval" Here is the full error text:
ReferenceError: /home/adam/Documents/Node/node-authentication/views/signup.ejs:26 24| --> 25| >> 26| <% if (req.params.missingFields) {%> 27| BLAH 28| <% } %> 29| req is not defined at eval (eval at (/home/adam/Documents/Node/node-authentication/node_modules/ejs/lib/ejs.js:237:14), :31:825) at eval (eval at (/home/adam/Documents/Node/node-authentication/node_modules/ejs/lib/ejs.js:237:14), :31:2194) at /home/adam/Documents/Node/node-authentication/node_modules/ejs/lib/ejs.js:250:15 at Object.exports.render (/home/adam/Documents/Node/node-authentication/node_modules/ejs/lib/ejs.js:288:13) at View.exports.renderFile [as engine] (/home/adam/Documents/Node/node-authentication/node_modules/ejs/lib/ejs.js:318:20) at View.render (/home/adam/Documents/Node/node-authentication/node_modules/express/lib/view.js:76:8) at Function.app.render (/home/adam/Documents/Node/node-authentication/node_modules/express/lib/application.js:502:10) at ServerResponse.res.render (/home/adam/Documents/Node/node-authentication/node_modules/express/lib/response.js:777:7) at Object.handle (/home/adam/Documents/Node/node-authentication/routes/routes.js:35:7) at next_layer (/home/adam/Documents/Node/node-authentication/node_modules/express/lib/router/route.js:103:13)
mongodb
andpassport
tags included? – Max