我正在开发一个应用程序来验证 Facebook 用户的身份。 我对 Sails 和 Passport 都很陌生,所以我决定关注这个存储库:https://github.com/stefanbuck/sails-social-auth-example
我忠实地遵循了这个存储库,并且能够如此轻松地使用 facebook 进行登录功能,但是注销功能将不起作用。
在 routes.js 中是:
'/logout' : {
controller : 'auth',
action : 'logout'
}
在 AuthController.js 中是:
logout: function (req, res) {
req.logout();
res.redirect('/');
}
当我停止服务器提升时,注销似乎完成了,下次我执行命令 sails lift
时,它警告我:
warn: handshake error No cookie transmitted with socket.io connection. Are you trying to access your Sails.js server via socket.io on a 3rd party domain? If you're ok with losing users' session data, you can set `authorization: false` to disable cookie-checking. Or you can send a JSONP request first from the client to the Sails.js server to get the cookie (be sure it's the same domain!!)
我不知道如何处理。
你能告诉我哪里出了问题吗?我该如何解决?
- sails v0.0.4
- Passport v0.3.4
- Passport -facebook v1.0.0
最佳答案
我也将 Passport 与 Sails 一起使用,我的 routes.js 将注销作为“帖子”
'post /logout':{
controller: 'user',
action: 'logout'
},
和我的注销功能是一样的,可以解决你的问题吗?
如果有帮助的话,这也是我的观点:
<form action="/logout" method="post">
<input type="submit" value="Log Out"/>
</form>
关于node.js - 风 sails + Passport : Logging out won't work,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18746294/