From ff466e57ac6db9a62609fb0c75ab9909765bcc13 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Wed, 4 Oct 2017 01:40:41 +0300 Subject: [PATCH] Use a guard clause instead of condition #600 --- app/controllers/registrar/base_controller.rb | 10 +++++----- app/controllers/registrar/sessions_controller.rb | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/controllers/registrar/base_controller.rb b/app/controllers/registrar/base_controller.rb index 0455b2a2e..2a0d0a7aa 100644 --- a/app/controllers/registrar/base_controller.rb +++ b/app/controllers/registrar/base_controller.rb @@ -19,11 +19,11 @@ class Registrar ip_restriction = Authorization::RestrictedIP.new(request.ip) allowed = ip_restriction.can_access_registrar_area?(current_user.registrar) - unless allowed - flash[:alert] = t('registrar.authorization.ip_not_allowed', ip: request.ip) - sign_out current_user - redirect_to registrar_login_url - end + return if allowed + + flash[:alert] = t('registrar.authorization.ip_not_allowed', ip: request.ip) + sign_out current_user + redirect_to registrar_login_url end def depp_controller? diff --git a/app/controllers/registrar/sessions_controller.rb b/app/controllers/registrar/sessions_controller.rb index 8d6692350..8f9c71b1b 100644 --- a/app/controllers/registrar/sessions_controller.rb +++ b/app/controllers/registrar/sessions_controller.rb @@ -153,9 +153,9 @@ class Registrar ip_restriction = Authorization::RestrictedIP.new(request.ip) allowed = ip_restriction.can_access_registrar_area_sign_in_page? - unless allowed - render text: t('registrar.authorization.ip_not_allowed', ip: request.ip), status: :forbidden - end + return if allowed + + render text: t('registrar.authorization.ip_not_allowed', ip: request.ip), status: :forbidden end end end