加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-16 20:39:13 所属栏目:百科 来源:网络整理
导读:如何在rails应用程序中设置,如果任何用户空闲30分钟或特定的时间段,他应该自动注销. 任何一个可以给任何解决方案.我正在使用devise进行身份验证.任何帮助是赞赏. 解决方法 您应该使用 Timeoutable 型号特征. Timeoutable takes care of veryfing whether a u
如何在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,你可以在那里配置超时值.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读