node.js - 风 sails + Passport : Logging out won't work

标签 node.js sails.js passport.js

我正在开发一个应用程序来验证 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/

相关文章:

javascript - 在 sails.js 中区分移动版本和桌面版本的最简单方法是什么

javascript - 如何自动登录用户node.js Passport.js

javascript - 如何将 Mongoose/Mongodb 与 node.js- Passport 身份验证一起使用

javascript - 如何在 https.get 调用 node.js 时禁用证书缓存?

node.js - 在 Heroku 上部署 Meteor 0.9.2.1

node.js - 将 redis 与 Passportjs 一起用于 session 不起作用

node.js - 使用本地策略进行身份验证时,Passportjs 抛出 500 服务器错误

javascript - Node js 服务器 : I want to respond to a browser request with both HTML and JSON in the same response, 这可能吗?

javascript - 如何在 Sails.js 中保护蓝图访问

javascript - Node.js NPM 模块与流行框架的兼容性