活动/闲置后自动注销 [英] automatic logout after inactivity/idle

查看:107
本文介绍了活动/闲置后自动注销的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何设置的Rails应用程序,如果任何用户空闲30分钟或一个特定的时间段,他应该得到自动注销。
任何一个可以给出任何解决方案。我使用的设计验证的目的。任何帮助是AP preciated。

How to set up in the rails application that if any user is idle for 30 minutes or a specific period of time he should be automatically get logged out. Can any one give any solution . i am using devise for authentication purpose. Any help is appreciated .

推荐答案

您应该使用<一个href=\"http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Timeoutable\"><$c$c>Timeoutable模型的特点。

You should use Timeoutable model trait.

Timeoutable需要veryfing用户会话是否已经过期或不照顾。当配置的时间后,会话过期后,用户将被要求提供凭据再次,这意味着,他/她将被重定向到登录页。

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.

Timeoutable添加以下选项devise_for:

Timeoutable adds the following options to devise_for:


      
  • + timeout_in +:无活动超时用户会话的时间间隔

  •   

在你的模型需要

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

另外,看看配置/初始化/ devise.rb ,你可以有配置超时值。

Also, take a look at config/initializers/devise.rb, you can configure timeout value there.

这篇关于活动/闲置后自动注销的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆