【问题标题】:Automatic logout inactivity/idle after 2 or 3 minutes my application我的应用程序 2 或 3 分钟后自动注销不活动/空闲
【发布时间】:2017-01-12 07:18:31
【问题描述】:

如何在 Rails 应用程序中设置如果用户空闲或不活动 30 分钟,他应该自动退出。我正在使用设计进行身份验证。

我有这样的设置,但不起作用。

config/initializers/session_store.rb

Rails.application.config.session_store ActionDispatch::Session::CacheStore, :expire_after => 30.minutes, key: Settings.server.session_key, domain: ".#{Settings.server.domain}"

任何人都可以给出任何解决方案。

【问题讨论】:

    标签: ruby ruby-on-rails-4


    【解决方案1】:

    您需要在 User.rb 或您用于设计的任何模型中添加 :timeoutable

    devise :database_authenticatable, :registerable,:recoverable, :rememberable, :trackable, :validatable, :timeoutable
    

    然后在你的 devise.rb 中取消注释这一行。

    > # ==> Configuration for :timeoutable
    > # The time you want to timeout the user session without activity. After this
    > # time the user will be asked for credentials again. Default is 30 minutes.
    
    
    config.timeout_in = 30.minutes
    

    设置任何你想要的时间。

    【讨论】:

      猜你喜欢
      • 2013-01-12
      • 2014-10-20
      • 2011-08-04
      • 2013-04-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-13
      相关资源
      最近更新 更多