同一用户的Authlogic和多个会话

Dam*_*IEU 7 ruby authentication ruby-on-rails authlogic

我正在使用Authlogic来管理我的应用程序中的会话.
但是,默认情况下,authlogic允许用户从不同的计算机多次登录.
我不希望这样(用户付费获取访问权限,我希望避免用户共享其帐户).

查看Authlogic文档,我发现了perishable_token.但是当试图实现它时,我只是得到一个错误,说persistence_token是必需的(当它不应该是我使用易腐烂的那个).

你会如何使用Authlogic的功能?

谢谢 :)

Dam*_*IEU 17

好吧,易腐坏的令牌绝对不是正确的道路;)

每次用户登录或注销时,我们"只需"重置持久性令牌.在我的UserSession模型中,每个用户在登录时都会从任何其他会话中注销.

class UserSession < Authlogic::Session::Base
    before_destroy :reset_persistence_token
    before_create  :reset_persistence_token

    def reset_persistence_token
        record.reset_persistence_token
    end 
end
Run Code Online (Sandbox Code Playgroud)