mirror of
https://github.com/internetee/registry.git
synced 2025-07-25 20:18:22 +02:00
Refactor Devise integration
- Use scoped users - Use the named route helpers instead of hardcoded paths
This commit is contained in:
parent
c31f507c25
commit
9684c8e59f
52 changed files with 313 additions and 280 deletions
|
@ -2,7 +2,7 @@ class Registrar
|
|||
class BaseController < ApplicationController
|
||||
include Registrar::ApplicationHelper
|
||||
|
||||
before_action :authenticate_user!
|
||||
before_action :authenticate_registrar_user!
|
||||
before_action :check_ip_restriction
|
||||
helper_method :depp_controller?
|
||||
helper_method :head_title_sufix
|
||||
|
@ -10,21 +10,21 @@ class Registrar
|
|||
protected
|
||||
|
||||
def current_ability
|
||||
@current_ability ||= Ability.new(current_user, request.remote_ip)
|
||||
@current_ability ||= Ability.new(current_registrar_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)
|
||||
allowed = ip_restriction.can_access_registrar_area?(current_registrar_user.registrar)
|
||||
|
||||
return if allowed
|
||||
|
||||
sign_out current_user
|
||||
sign_out current_registrar_user
|
||||
|
||||
flash[:alert] = t('registrar.authorization.ip_not_allowed', ip: request.ip)
|
||||
redirect_to registrar_login_url
|
||||
redirect_to new_registrar_user_session_url
|
||||
end
|
||||
|
||||
def depp_controller?
|
||||
|
@ -34,5 +34,9 @@ class Registrar
|
|||
def head_title_sufix
|
||||
t(:registrar_head_title_sufix)
|
||||
end
|
||||
|
||||
def user_for_paper_trail
|
||||
current_registrar_user.present? ? current_registrar_user.id_role_username : 'public'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue