rails 3.1, devise gem, :timeoutable is not working, why?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-07 19:28:13

问题


I am trying to use the auto signout feature,

here is my model:

class Student < ActiveRecord::Base

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

  def timeout
      3.seconds
  end
end

here is the routes.rb:

  devise_for :students do get '/students/sign_out' => 'students/sessions#destroy' end

I sign-in, then I wait 5 seconds, at this time, student session should be expired, but, if vavigating to any other protected page is not redirecting back to login form, meaning that the session is still active.

Is there something I am missing ?? what shall I check ?

Thanks, hopewise


回答1:


There is an incorrect information on devise wiki. The correct method is timeout_in.

I've fixed the wiki page https://github.com/plataformatec/devise/wiki/How-To:-Add-timeout_in-value-dynamically.




回答2:


I found the solution, the config.timeout_in was commented at the file devise.rb at config/initializers folder

I thought that adding :timeoutable is all what I have to do, I think devise.rb at config/initializers should be added to the documentation beside talking about :timeoutable, it will be helpful for RoR newbies.



来源:https://stackoverflow.com/questions/8331701/rails-3-1-devise-gem-timeoutable-is-not-working-why

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!