限制 rails 上的设备数量
Restricting number of devices on rails
我正在做一个 rails 项目,我希望限制每个用户只能使用 2 台设备访问我的应用程序(以限制用户名和密码共享)。我目前正在使用 Devise 进行用户身份验证。我已经通过 SO 和 Devise 文档对此进行了研究,但尚未找到任何解决方案。我当然不可能是第一个有这种需求的人。有人对如何实现这一点有任何想法吗?
您可以通过在数据库中存储您的设备唯一 ID 来做到这一点。
创建一个单独的 table,您可以在其中存储您登录的设备 ID 并在验证时检查。
对于硬件相关的标识密钥,我们也可以使用 MAC 地址。
A Media Access Control address (MAC address) is a unique identifier
assigned to network interfaces for communications on the physical
network segment. MAC addresses are most often assigned by the
manufacturer of a network interface card (NIC) and are stored in its
hardware, the card's read-only memory, or some other firmware
mechanism. [wikipedia]
这里有一个 gem 用于查找 mac 地址:
https://github.com/ahoward/macaddr
我正在做一个 rails 项目,我希望限制每个用户只能使用 2 台设备访问我的应用程序(以限制用户名和密码共享)。我目前正在使用 Devise 进行用户身份验证。我已经通过 SO 和 Devise 文档对此进行了研究,但尚未找到任何解决方案。我当然不可能是第一个有这种需求的人。有人对如何实现这一点有任何想法吗?
您可以通过在数据库中存储您的设备唯一 ID 来做到这一点。
创建一个单独的 table,您可以在其中存储您登录的设备 ID 并在验证时检查。
对于硬件相关的标识密钥,我们也可以使用 MAC 地址。
A Media Access Control address (MAC address) is a unique identifier assigned to network interfaces for communications on the physical network segment. MAC addresses are most often assigned by the manufacturer of a network interface card (NIC) and are stored in its hardware, the card's read-only memory, or some other firmware mechanism. [wikipedia]
这里有一个 gem 用于查找 mac 地址:
https://github.com/ahoward/macaddr