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

标签 javascript node.js everyauth

到目前为止,我一直在使用客户端身份验证。我刚刚设置了服务器端的 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/

相关文章:

javascript - JavaScript 中数字方法的奇怪语法

javascript - 单击行时如何突出显示 JSF 行

javascript - 继承方法调用触发 Typescript 编译器错误

facebook - node.js - everyuth - Facebook API 和 session 处理

session - 如何在Everyauth的.findOrCreateUser上获取Express sessionID?

javascript - 如何在调整特定宽度的窗口后使背景图像响应?

javascript - 事件不起作用?

javascript - Firebase:TypeError:无法读取未定义的属性(读取 'getIdToken')

node.js - 如何使用 mongodb 聚合计算数组字段的百分比?