Commit bb696da4 authored by Pedro Henrique's avatar Pedro Henrique

Implements timeout session

Signed-off-by: Pedro Henrique's avatarPedro Henrique! <pha14@inf.ufpr.br>
parent 2977b663
......@@ -28,6 +28,16 @@ class ApplicationController < ActionController::Base
before_filter :check_role, unless: :devise_controller?
before_action :load_professional_service_place, except: [:check_role]
before_filter :check_signin
protect_from_forgery
def check_signin
if session[:expires_at] && session[:expires_at].to_time < Time.current
sign_out
flash[:notice] = "Sua sessão expirou"
end
end
# write access log
def write_log
if params
......
......@@ -32,6 +32,8 @@ class SessionsController < Devise::SessionsController
# return redirect_to root_path
# end
# Set expires time to send message when expiring
session[:expires_at] = Time.current + 30.minutes
# Set variable to show loading bar
session[:carrega_pagina] = true
# Set active role to nil
......
# Be sure to restart your server when you modify this file.
Agendador::Application.config.session_store :cookie_store, key: '_agendador_session'
Agendador::Application.config.session_store(
:cookie_store,
key: '_agendador_session',
expire_after: 30.minutes
)
# If change expire_after change also session[:expires_at] at sessions_controller.rb
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment