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

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 ...@@ -15,8 +15,8 @@ class ProfessionalsServicePlacesController < ApplicationController
redirect_to root_path redirect_to root_path
else else
if params[:id] == "0" if params[:id] == "0"
@currentCityHall = CityHall.where(:city_id => current_citizen.city_id).first @currentCityHall = CityHall.find_by(:city_id => current_citizen.city_id)
if @currentCityHall.citizen_access if @currentCityHall.citizen_access && @currentCityHall.active
session[:active_role] = 0 session[:active_role] = 0
......
...@@ -27,7 +27,7 @@ class SessionsController < Devise::SessionsController ...@@ -27,7 +27,7 @@ class SessionsController < Devise::SessionsController
# 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? && current_city.active if !resource.nil? && citizen_signed_in?
# if !resource.active # if !resource.active
# sign_out(resource) # sign_out(resource)
...@@ -54,14 +54,24 @@ class SessionsController < Devise::SessionsController ...@@ -54,14 +54,24 @@ class SessionsController < Devise::SessionsController
redirect_to choose_role_path redirect_to choose_role_path
end end
else else
# Define as citizen # If this citizen has only a citizen permission check if city in active
session[:active_role] = 0 if current_city.active && current_city.citizen_access
redirect_to root_path # 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 end
else else
if !current_city.active || (!@current_city_hall.citizen_access) if !current_city.active || (!current_city.citizen_access)
sign_out(resource) 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 if @city_hall && @city_hall.textoBloqueio
mensagem += @city_hall.textoBloqueio mensagem += @city_hall.textoBloqueio
end 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