【问题标题】:Where can i find req.isAuthenticated() function in MEAN.JS?我在哪里可以找到 MEAN.JS 中的 req.isAuthenticated() 函数?
【发布时间】:2016-05-23 20:32:26
【问题描述】:

我正在使用 MEAN.JS,但我无法在该 MEAN.JS 中找到 req.isAuthenticated() 函数。请检查此链接

https://github.com/meanjs/mean/releases/tag/v0.3.3

我正在使用相同的代码进行学习,请有人帮助我...

【问题讨论】:

  • “找不到”在哪方面?您能否更具体地说明您遇到了什么问题?
  • 它是 passport 库提供的中间件 - github.com/jaredhanson/passport/blob/…
  • 我已经安装了 MEAN.JS,我只使用服务器端代码。我没有使用前端角度代码。我正在使用不同的服务器。对于前端(客户端)我正在维护一个服务,对于后端(服务器端)我正在使用 MEAN.JS。注册和登录工作正常,但是当我创建文章时出现错误“用户未登录”我该如何解决这个问题。请有人帮助我。 -乔·克莱
  • 感谢@Krzysztof Safjanowski

标签: node.js express mean-stack meanjs


【解决方案1】:

在 git hub 上找到它。 https://github.com/jaredhanson/passport/blob/a892b9dc54dce34b7170ad5d73d8ccfba87f4fcf/lib/passport/http/request.js#L74

req.isAuthenticated = function() {
  var property = 'user';
  if (this._passport && this._passport.instance._userProperty) {
    property = this._passport.instance._userProperty;
  }
return (this[property]) ? true : false;
};

P.S.:我刚刚注意到评论部分已经提供了链接。不过,我还是把答案留在这里,以便快速参考函数

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-03-06
    • 1970-01-01
    • 1970-01-01
    • 2023-01-30
    • 2017-11-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多