mirror of
https://github.com/internetee/registry.git
synced 2025-07-21 18:26:06 +02:00
parent
787cca8e4c
commit
35afbf1f8c
15 changed files with 304 additions and 54 deletions
|
@ -1,40 +1,37 @@
|
|||
class Registrar
|
||||
class BaseController < ApplicationController
|
||||
before_action :authenticate_user!, :check_ip
|
||||
|
||||
include Registrar::ApplicationHelper
|
||||
|
||||
before_action :authenticate_user!
|
||||
before_action :check_ip_restriction
|
||||
helper_method :depp_controller?
|
||||
|
||||
def depp_controller?
|
||||
false
|
||||
end
|
||||
|
||||
def check_ip
|
||||
return unless current_user
|
||||
unless current_user.is_a? ApiUser
|
||||
sign_out(current_user)
|
||||
return
|
||||
end
|
||||
|
||||
registrar_ip_whitelisted = current_user.registrar.registrar_ip_white?(request.ip)
|
||||
|
||||
return if registrar_ip_whitelisted
|
||||
flash[:alert] = t('ip_is_not_whitelisted')
|
||||
sign_out(current_user)
|
||||
redirect_to registrar_login_path and return
|
||||
end
|
||||
|
||||
helper_method :head_title_sufix
|
||||
|
||||
def head_title_sufix
|
||||
t(:registrar_head_title_sufix)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def current_ability
|
||||
@current_ability ||= Ability.new(current_user, request.remote_ip)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def check_ip_restriction
|
||||
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
|
||||
end
|
||||
|
||||
def depp_controller?
|
||||
false
|
||||
end
|
||||
|
||||
def head_title_sufix
|
||||
t(:registrar_head_title_sufix)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue