Add time limit for inactive sessions

closes #8
This commit is contained in:
Râu Cao 2023-02-19 13:44:48 +08:00
parent 90680368fb
commit e2618de7c6
Signed by: raucao
GPG Key ID: 15E65F399D084BA9
3 changed files with 7 additions and 2 deletions

View File

@ -4,6 +4,10 @@ export default class extends Controller {
static targets = ["buttons", "countdown"] static targets = ["buttons", "countdown"]
connect() { connect() {
// Devise timeoutable ends up adding a second flash message without content
// TODO investigate bug
if (this.element.textContent.trim() == "true") return;
const timeoutSeconds = parseInt(this.data.get("timeout")); const timeoutSeconds = parseInt(this.data.get("timeout"));
setTimeout(() => { setTimeout(() => {

View File

@ -38,7 +38,8 @@ class User < ApplicationRecord
devise :ldap_authenticatable, devise :ldap_authenticatable,
:confirmable, :confirmable,
:recoverable, :recoverable,
:validatable :validatable,
:timeoutable
def ldap_before_save def ldap_before_save
self.email = Devise::LDAP::Adapter.get_ldap_param(self.cn, "mail").first self.email = Devise::LDAP::Adapter.get_ldap_param(self.cn, "mail").first

View File

@ -210,7 +210,7 @@ Devise.setup do |config|
# ==> Configuration for :timeoutable # ==> Configuration for :timeoutable
# The time you want to timeout the user session without activity. After this # 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. # time the user will be asked for credentials again. Default is 30 minutes.
# config.timeout_in = 30.minutes config.timeout_in = 24.hours
# ==> Configuration for :lockable # ==> Configuration for :lockable
# Defines which strategy will be used to lock an account. # Defines which strategy will be used to lock an account.