代码之家  ›  专栏  ›  技术社区  ›  tybro0103

通过rails中的身份验证令牌查找用户?

  •  0
  • tybro0103  · 技术社区  · 15 年前

    所以对于一个特定的项目,我认为能够获取一个身份验证令牌并找出它是为哪个用户服务的可能对我很有用。我不确定这是否可能。有人知道吗?

    1 回复  |  直到 14 年前
        1
  •  0
  •   Trevoke    15 年前

    Authlogic (example app linked) 使用“持久性令牌”。

        t.string    :login,               :null => false                # optional, you can use email instead, or both
        t.string    :email,               :null => false                # optional, you can use login instead, or both
        t.string    :crypted_password,    :null => false                # optional, see below
        t.string    :password_salt,       :null => false                # optional, but highly recommended
        t.string    :persistence_token,   :null => false                # required
        t.string    :single_access_token, :null => false                # optional, see Authlogic::Session::Params
        t.string    :perishable_token,    :null => false                # optional, see Authlogic::Session::Perishability
    
        # Magic columns, just like ActiveRecord's created_at and updated_at. These are automatically maintained by Authlogic if they are present.
        t.integer   :login_count,         :null => false, :default => 0 # optional, see Authlogic::Session::MagicColumns
        t.integer   :failed_login_count,  :null => false, :default => 0 # optional, see Authlogic::Session::MagicColumns
        t.datetime  :last_request_at                                    # optional, see Authlogic::Session::MagicColumns
        t.datetime  :current_login_at                                   # optional, see Authlogic::Session::MagicColumns
        t.datetime  :last_login_at                                      # optional, see Authlogic::Session::MagicColumns
        t.string    :current_login_ip                                   # optional, see Authlogic::Session::MagicColumns
        t.string    :last_login_ip                                      # optional, see Authlogic::Session::MagicColumns
    

    这也许不是你想要的,但我认为你可以做到。真正的问题是,你为什么要这样做?