Commit e9624af0 authored by Pedro Henrique's avatar Pedro Henrique

Blocks citizen when trying to login in an inactive city

Signed-off-by: Pedro Henrique's avatarPedro Henrique! <pha14@inf.ufpr.br>
parent 98847996
...@@ -21,10 +21,13 @@ class SessionsController < Devise::SessionsController ...@@ -21,10 +21,13 @@ class SessionsController < Devise::SessionsController
# yield resource if block_given? # yield resource if block_given?
# respond_with resource, location: after_sign_in_path_for(resource) # 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 # Get resource
self.resource = warden.authenticate!(auth_options) self.resource = warden.authenticate!(auth_options)
# Check if resource is not null and if a citizen has been signed_in # 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 # if !resource.active
# sign_out(resource) # sign_out(resource)
...@@ -32,7 +35,7 @@ class SessionsController < Devise::SessionsController ...@@ -32,7 +35,7 @@ class SessionsController < Devise::SessionsController
# return redirect_to root_path # return redirect_to root_path
# end # end
# Set expires time to send message when expiring # Set expiretion time to send message when expiring session
session[:expires_at] = Time.current + 30.minutes session[:expires_at] = Time.current + 30.minutes
# Set variable to show loading bar # Set variable to show loading bar
session[:carrega_pagina] = true session[:carrega_pagina] = true
...@@ -56,11 +59,10 @@ class SessionsController < Devise::SessionsController ...@@ -56,11 +59,10 @@ class SessionsController < Devise::SessionsController
redirect_to root_path redirect_to root_path
end end
else else
if (!@current_city_hall.citizen_access) if !current_city.active || (!@current_city_hall.citizen_access)
sign_out(resource) sign_out(resource)
mensagem = "A utilização do agendador pela internet está mensagem = "A utilização do agendador nesta cidade está desativado"
desatibilitada nesta cidade. " if @city_hall && @city_hall.textoBloqueio
if @city_hall.textoBloqueio
mensagem += @city_hall.textoBloqueio mensagem += @city_hall.textoBloqueio
end end
return redirect_to root_path, alert: mensagem.html_safe return redirect_to root_path, alert: mensagem.html_safe
......
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