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

查看:79
本文介绍了拿起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.

推荐答案

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

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天全站免登陆