mirror of
https://github.com/internetee/registry.git
synced 2025-07-26 04:28:27 +02:00
parent
c1875ec88e
commit
787cca8e4c
9 changed files with 134 additions and 46 deletions
12
app/controllers/registrar/current_user_controller.rb
Normal file
12
app/controllers/registrar/current_user_controller.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
class Registrar
|
||||
class CurrentUserController < BaseController
|
||||
skip_authorization_check
|
||||
|
||||
def switch
|
||||
new_user = ApiUser.find(params[:new_user_id])
|
||||
sign_in(new_user) if new_user.identity_code == current_user.identity_code
|
||||
|
||||
redirect_to :back, notice: t('.switched', new_user: new_user)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -61,27 +61,6 @@ class Registrar
|
|||
end
|
||||
end
|
||||
|
||||
# rubocop:enable Metrics/MethodLength
|
||||
# rubocop:enable Metrics/AbcSize
|
||||
|
||||
def switch_user
|
||||
@api_user = ApiUser.find(params[:id])
|
||||
|
||||
unless Rails.env.development?
|
||||
unless @api_user.registrar.registrar_ip_white?(request.ip)
|
||||
flash[:alert] = I18n.t(:ip_is_not_whitelisted)
|
||||
redirect_to :back and return
|
||||
end
|
||||
end
|
||||
|
||||
sign_in @api_user if @api_user.identity_code == current_user.identity_code
|
||||
|
||||
redirect_to registrar_root_url
|
||||
end
|
||||
|
||||
# rubocop:enable Metrics/CyclomaticComplexity
|
||||
# rubocop:enable Metrics/PerceivedComplexity
|
||||
|
||||
def id
|
||||
@user = ApiUser.find_by_idc_data(request.env['SSL_CLIENT_S_DN'])
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue