Authlogic and multiple sessions for the same user

前端 未结 1 1895
温柔的废话
温柔的废话 2020-12-16 21:53

I\'m using Authlogic to manage the sessions in my application.
However, by default, authlogic allows a user to be logged in many times from different computers.
I do

相关标签:
1条回答
  • 2020-12-16 22:17

    Ok so the perishable token was absolutely not the right path ;)

    We "just" need to reset the persistence token every time a user logs in or logs out. With this in my UserSession model, every user gets logged off from any other session when logging in.

    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
    
    0 讨论(0)
提交回复
热议问题