ruby-on-rails – 不活动/空闲后自动注销

如何在rails应用程序中设置,如果任何用户空闲30分钟或特定的时间段,他应该自动注销.
任何一个可以给任何解决方案.我正在使用devise进行身份验证.任何帮助是赞赏.

解决方法

您应该使用 Timeoutable型号特征.

Timeoutable takes care of veryfing whether a user session has already expired or not. When a session expires after the configured time,the user will be asked for credentials again,it means,he/she will be redirected to the sign in page.

Options

Timeoutable adds the following options to devise_for:

  • +timeout_in+: the interval to timeout the user session without activity.

在你需要的模型中

devise :timeoutable
# along with :database_authenticatable,:registerable and other things.

另外,看一下config / initializers / devise.rb,你可以在那里配置超时值.

相关文章

validates:conclusion,:presence=>true,:inclusion=>{...
一、redis集群搭建redis3.0以前,提供了Sentinel工具来监控各...
分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣...
上一篇博文 ruby传参之引用类型 里边定义了一个方法名 mo...
一编程与编程语言 什么是编程语言? 能够被计算机所识别的表...
Ruby类和对象Ruby是一种完美的面向对象编程语言。面向对象编...