How do I add Devise's 'timeoutable' module to an existing Devise install? - Rails 3.1

扶醉桌前 提交于 2019-12-03 09:38:13

timeoutable refers to the login session timeout. No extra columns are needed, just add it to your model.

The timeoutable hook contains all the magic (source: https://github.com/plataformatec/devise/blob/master/lib/devise/hooks/timeoutable.rb)

You only need add timeoutable to your user model:

devise :timeoutable

And set the interval time in config/initializers/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

Just add to your model:

devise :timeoutable, timeout_in: XX.minutes

replace XX with the number of minutes you want.

timeoutable not working if you are have remember_me = true

https://github.com/plataformatec/devise/blob/master/lib/devise/hooks/timeoutable.rb#L26

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