Skip to content

Commit

Permalink
Enable Devise timeoutable module
Browse files Browse the repository at this point in the history
Expire the user session after 1 hour of inactivity.

Timeoutable uses the FlashHash as global storage which causes issues when displaying flash messages. The workaround is to skip non String values. More info on heartcombo/devise#1777
  • Loading branch information
leoapost committed Mar 30, 2020
1 parent b5044a0 commit 654f650
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class User < ActiveRecord::Base
:validatable,
:invitable,
:registerable,
:confirmable
:confirmable,
:timeoutable

scope :active, -> { where('current_sign_in_at >= ?', inactivate_date) }
scope :inactive, (lambda do
Expand Down
1 change: 1 addition & 0 deletions app/views/layouts/application.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
.govuk-error-summary__body
ul.govuk-list.govuk-error-summary__list
- flash.each do |key, value|
- next unless value.is_a? String
li class="#{key}" data-alert='' #{value.html_safe}


Expand Down
2 changes: 1 addition & 1 deletion config/initializers/devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@
# ==> 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
config.timeout_in = 1.hour

# If true, expires auth token on session timeout.
# config.expire_auth_token_on_timeout = false
Expand Down

0 comments on commit 654f650

Please sign in to comment.