Commit 8ae0b18c authored by Pedro Henrique's avatar Pedro Henrique

fix block citizen login when city is inactive

Signed-off-by: Pedro Henrique's avatarPedro Henrique! <pha14@inf.ufpr.br>
parent 2ddc4e86
......@@ -15,8 +15,8 @@ class ProfessionalsServicePlacesController < ApplicationController
redirect_to root_path
else
if params[:id] == "0"
@currentCityHall = CityHall.where(:city_id => current_citizen.city_id).first
if @currentCityHall.citizen_access
@currentCityHall = CityHall.find_by(:city_id => current_citizen.city_id)
if @currentCityHall.citizen_access && @currentCityHall.active
session[:active_role] = 0
......
......@@ -27,7 +27,7 @@ class SessionsController < Devise::SessionsController
# 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? && current_city.active
if !resource.nil? && citizen_signed_in?
# if !resource.active
# sign_out(resource)
......@@ -54,14 +54,24 @@ class SessionsController < Devise::SessionsController
redirect_to choose_role_path
end
else
# Define as citizen
session[:active_role] = 0
redirect_to root_path
# If this citizen has only a citizen permission check if city in active
if current_city.active && current_city.citizen_access
# Define as citizen
session[:active_role] = 0
redirect_to root_path
else
sign_out(resource)
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
end
end
else
if !current_city.active || (!@current_city_hall.citizen_access)
if !current_city.active || (!current_city.citizen_access)
sign_out(resource)
mensagem = "A utilização do agendador nesta cidade está desativado"
mensagem = "A utilização do agendador nesta cidade está desativado. "
if @city_hall && @city_hall.textoBloqueio
mensagem += @city_hall.textoBloqueio
end
......
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