【问题标题】:Sails+Passport: Logging out won't workSails+Passport:注销无效
【发布时间】:2015-04-18 02:37:08
【问题描述】:

我正在制作一个通过 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!!)

我不明白如何处理。

你能告诉我哪里出了问题,我该如何让它发挥作用?

  • 帆 v0.0.4
  • 护照 v0.3.4
  • passport-facebook v1.0.0

【问题讨论】:

  • 你可以先尝试销毁会话对象; req.session.destroy 然后在回调中您可以重定向。 res.redirect.

标签: node.js sails.js passport.js


【解决方案1】:

我也将 Passport 与 Sails 一起使用,我的 routes.js 已注销为“帖子”

'post /logout':{
    controller: 'user',
    action: 'logout'
},

和我的注销功能一样,可以解决你的问题吗?

如果有帮助,这也是我的观点:

<form action="/logout" method="post">
    <input type="submit" value="Log Out"/>
</form>

【讨论】:

    猜你喜欢
    • 2014-03-19
    • 2023-03-18
    • 2019-05-09
    • 2018-06-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-09
    相关资源
    最近更新 更多