“ensureAuthentication"文档“已认证"护照的作用?

编程入门 行业动态 更新时间:2024-10-24 14:24:31
本文介绍了“ensureAuthentication"文档“已认证"护照的作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我一直在寻找一段时间,但找不到明确的文档来源.当我搜索这些时,第一个 Google 搜索结果是 StackOverflow.

I've been looking for a while, and can't see to find a definitive documentation source. When I search for these, the first Google results are to StackOverflow.

还有类似的中间件功能吗?

Are there any more middleware functions similar to this?

推荐答案

虽然没有在任何容易找到的地方明确记录,但您可以看到 isAuthenticated 和 isUn​​authenticated 标志的位置在 github/jaredhanson/的 Passport 代码中设置护照/blob/a892b9dc54dce34b7170ad5d73d8ccfba87f4fcf/lib/passport/http/request.js#L74.

While not explicitly documented anywhere easily found, you can see where the the isAuthenticated and isUnauthenticated flags are set in the Passport code at github/jaredhanson/passport/blob/a892b9dc54dce34b7170ad5d73d8ccfba87f4fcf/lib/passport/http/request.js#L74.

ensureAuthenticated 不是官方的,但可以通过以下方式实现:

ensureAuthenticated is not official, but can be implemented via the following:

function ensureAuthenticated(req, res, next) { if (req.isAuthenticated()) return next(); else // Return error content: res.jsonp(...) or redirect: res.redirect('/login') } app.get('/account', ensureAuthenticated, function(req, res) { // Do something with user via req.user });

更多推荐

“ensureAuthentication"文档“已认证"护照的作用?

本文发布于:2023-11-12 23:47:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1582846.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:护照   作用   文档   ensureAuthentication   quot

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!