gpt4 book ai didi

javascript - 如何检查用户是否已经登录? (everyauth,node.js)

转载 作者:搜寻专家 更新时间:2023-10-31 23:49:44 26 4
gpt4 key购买 nike

到目前为止,我一直在使用客户端身份验证。我刚刚设置了服务器端的 everyauth,它运行良好,但是我如何在页面加载时执行 FB.getLoginStatus(我在客户端所做的)之类的操作?

如果用户已经登录,我不想让他们再次经历这个过程。

感谢您的解释!

最佳答案

来自documentation

everyauth also provides convenience methods on the ServerRequest instance req. From any scope that has access to req, you get the following convenience getters and methods:

req.loggedIn - a Boolean getter that tells you if the request is by a logged in user

req.user - the User document associated with the session

req.logout() - clears the sesion of your auth data

在快速 View 中:

If you are using express, everyauth comes with some useful dynamic helpers. To enable them:

var express = require('express')
, everyauth = require('everyauth')
, app = express.createServer();
everyauth.helpExpress(app);

Then, from within your views, you will have access to the following helpers methods attached to the helper, everyauth:

everyauth.loggedIn

关于javascript - 如何检查用户是否已经登录? (everyauth,node.js),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9029217/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com