我无法让我的系统注销PassportJS.似乎正在调用注销路由,但它不会删除会话.如果用户没有以特定路线登录,我希望它返回401.我调用authenticateUser来检查用户是否已登录.
非常感谢!
/******* This in index.js *********/
// setup passport for username & passport authentication
adminToolsSetup.setup(passport);
// admin tool login/logout logic
app.post("/adminTool/login",
passport.authenticate('local', {
successRedirect: '/adminTool/index.html',
failureRedirect: '/',
failureFlash: false })
);
app.get('/adminTool/logout', adminToolsSetup.authenticateUser, function(req, res){
console.log("logging out");
console.log(res.user);
req.logout();
res.redirect('/');
});
// ******* This is in adminToolSetup ********
// Setting up user authentication to be using user name and passport as authentication method,
// this function will fetch the user information from the user name, and compare the password …Run Code Online (Sandbox Code Playgroud) 我有一个Backbone Collection对象,其URL为"http:// localhost:8080/api/menu/1/featured".我正在尝试执行获取操作以从URL检索集合并解析它.但是,在服务器端,我为此请求看到的方法类型是OPTIONS.服务器只是支持GET方法.我不确定Backbone如何确定要使用的方法类型,以及为什么它有时会随机更改为OPTIONS方法类型.我正在使用Node.js服务器来处理请求.下面的代码几乎就是我所做的.
var FeaturedCollection = Backbone.Collection.extend({
model:FeaturedContent,
url:function () { return url_featured; },
parse:function (response) {
console.log(response);
return response;
}
});
var featuredCollection = new FeaturedCollection();
featuredCollection.fetch();
Run Code Online (Sandbox Code Playgroud)
请帮忙,谢谢!
我试图弄清楚如何使用Node.js的mongoose-joins.我试过看过ReadMe文件,它只解释了如何设置它.是否有实际加入两个数据集的示例代码?
javascript ×2
backbone.js ×1
express ×1
fetch ×1
jquery ×1
logout ×1
mongoose ×1
node.js ×1
options ×1
passport.js ×1