拿起meteor.js 用户注销 [英] Picking up meteor.js user logout

查看:21
本文介绍了拿起meteor.js 用户注销的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户退出网站时,有什么办法可以接听吗?当他们这样做时,我需要做一些清理工作.使用内置的meteor.js 用户帐户.

Is there any way to pick up when a user logs out of the website? I need to do some clean up when they do so. Using the built-in meteor.js user accounts.

我将使用它进行一些验证,所以我需要一个不能代表客户端的其他用户触发的解决方案 - 最好是完全服务器端的东西.

I'll be doing some validation using it, so I need a solution that cannot be trigger on behalf of other users on the client side - preferably something completely server side.

推荐答案

使用我创建的 user-status 包:https://github.com/mizzao/meteor-user-status.这完全是服务器端的.

Use the user-status package that I've created: https://github.com/mizzao/meteor-user-status. This is completely server-side.

有关用法,请参阅文档,但您可以将事件处理程序附加到会话注销:

See the docs for usage, but you can attach an event handler to a session logout:

UserStatus.events.on "connectionLogout", (fields) ->
  console.log(fields.userId + " with connection " + fields.connectionId + " logged out")

请注意,用户可以通过多个会话同时从不同位置登录.这个智能包检测所有这些以及用户是否在线.如需更多信息或实现您自己的方法,请查看代码.

Note that a user can be logged in from different places at once with multiple sessions. This smart package detects all of them as well as whether the user is online at all. For more information or to implement your own method, check out the code.

目前该软件包不区分浏览器窗口关闭和注销,并将它们视为相同.

Currently the package doesn't distinguish between browser window closes and logouts, and treats them as the same.

这篇关于拿起meteor.js 用户注销的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆