Commit 2ddc4e86 authored by Pedro Henrique's avatar Pedro Henrique

Merge branch 'Issue#139' into 'master'

Issue#139

See merge request !244
parents 88a553cf 9ca1dce0
......@@ -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
......
......@@ -21,10 +21,13 @@ class SessionsController < Devise::SessionsController
# yield resource if block_given?
# respond_with resource, location: after_sign_in_path_for(resource)
# Get status of current city
current_city = CityHall.find_by(city_id: current_citizen.city_id)
# Get resource
self.resource = warden.authenticate!(auth_options)
# Check if resource is not null and if a citizen has been signed_in
if !resource.nil? && citizen_signed_in?
if !resource.nil? && citizen_signed_in? && current_city.active
# if !resource.active
# sign_out(resource)
......@@ -32,6 +35,8 @@ class SessionsController < Devise::SessionsController
# return redirect_to root_path
# end
# Set expiretion time to send message when expiring session
session[:expires_at] = Time.current + 24.hours
# Set variable to show loading bar
session[:carrega_pagina] = true
# Set active role to nil
......@@ -54,11 +59,10 @@ class SessionsController < Devise::SessionsController
redirect_to root_path
end
else
if (!@current_city_hall.citizen_access)
if !current_city.active || (!@current_city_hall.citizen_access)
sign_out(resource)
mensagem = "A utilização do agendador pela internet está
desatibilitada nesta cidade. "
if @city_hall.textoBloqueio
mensagem = "A utilização do agendador nesta cidade está desativado"
if @city_hall && @city_hall.textoBloqueio
mensagem += @city_hall.textoBloqueio
end
return redirect_to root_path, alert: mensagem.html_safe
......
# 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: 24.hours
)
# 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