mirror of
https://github.com/internetee/registry.git
synced 2025-08-04 00:42:04 +02:00
Check IP in registrar
This commit is contained in:
parent
19e133ec6a
commit
940355a417
4 changed files with 33 additions and 2 deletions
|
@ -5,6 +5,8 @@ class Registrar::SessionsController < ::SessionsController
|
|||
false
|
||||
end
|
||||
|
||||
before_action :check_ip
|
||||
|
||||
def login
|
||||
@depp_user = Depp::User.new
|
||||
end
|
||||
|
@ -139,4 +141,11 @@ class Registrar::SessionsController < ::SessionsController
|
|||
return User.new unless idc
|
||||
ApiUser.find_by(identity_code: idc) || User.new
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def check_ip
|
||||
return if WhiteIp.registrar_ip_white?(request.ip)
|
||||
render text: t('ip_is_not_whitelisted') and return
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
class RegistrarController < ApplicationController
|
||||
before_action :authenticate_user!
|
||||
before_action :authenticate_user!, :check_ip
|
||||
# before_action :check_ip
|
||||
layout 'registrar/application'
|
||||
|
||||
include Registrar::ApplicationHelper
|
||||
|
@ -9,6 +10,14 @@ class RegistrarController < ApplicationController
|
|||
false
|
||||
end
|
||||
|
||||
def check_ip
|
||||
return unless current_user
|
||||
return if current_user.registrar.registrar_ip_white?(request.ip)
|
||||
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue