0
我想在出现错误凭据的情况下为用户显示错误消息。我怎么能在Express JS中做到这一点?我尝试了下面的代码,但它不起作用:在ExpressJS响应中发送JQuery Mobile错误消息
app.get('/', function(req, res, next) {
passport.authenticate('local', function(err, user, info) {
if (err) { return next(err) }
if (!user) { return res.send($("<div class='ui-loader ui-overlay-shadow ui-body-e ui-corner-all'><h1>YOUR MESSAGE</h1></div>")
.css({ "display": "block", "opacity": 0.96, "top": $(window).scrollTop() + 100 })
.appendTo($.mobile.pageContainer)
.delay(800)
.fadeOut(400, function() {
$(this).remove();
})
); }
req.logIn(user, function(err) {
if (err) { return next(err); }
return res.redirect('/account');
});
})(req, res, next);
});
这是什么问题?
谢谢,
这是什么呢? – Mustafa 2012-04-22 20:51:15
身份验证。查看并导航到自定义回调部分http://passportjs.org/guide/authenticate.html – 2012-04-23 03:10:38
不,我的意思是这段代码做了什么,有什么不起作用? – Mustafa 2012-04-23 07:45:32