Refactor IP registrar restriction

#600
This commit is contained in:
Artur Beljajev 2017-10-04 01:03:32 +03:00
parent 787cca8e4c
commit 35afbf1f8c
15 changed files with 304 additions and 54 deletions

View file

@ -0,0 +1,25 @@
module Authorization
class RestrictedIP
def initialize(ip)
@ip = ip
end
def self.enabled?
Setting.registrar_ip_whitelist_enabled
end
def can_access_registrar_area?(registrar)
return true unless self.class.enabled?
registrar.white_ips.registrar_area.include_ip?(ip)
end
def can_access_registrar_area_sign_in_page?
return true unless self.class.enabled?
WhiteIp.registrar_area.include_ip?(ip)
end
private
attr_reader :ip
end
end