我的目标很简单。如果用户正在尝试注册并在所有必填字段已满之前点击“提交”,我想将他或她重新导向到注册页面,但稍微更改一下,以便在每个必填字段旁边显示一个红色星号(这是我知道)任意和丑陋的选择。我想我不必为此目的单独看待。是否有可能以这种方式改变注册视图?如何将用户重定向到注册页面,但在必填字段旁边带有红色星号?
在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
}));
在signup.ejs
% if (req.params.missingFields) {%>
BLAH
<% } %>
我得到signup.ejs一个错误 “REQ没有在EVAL规定” 以下是完整的错误文本:
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'和'passport'标签? – 2014-08-28 03:07:24
我使用这些,我认为可能有一些包,或者我不知道这可以帮助我。 – michaelAdam 2014-08-28 03:09:33