mirror of
https://github.com/internetee/registry.git
synced 2025-07-21 02:05:57 +02:00
Switch user in registrar #2754
This commit is contained in:
parent
0c4e152abd
commit
0a0543c715
5 changed files with 32 additions and 2 deletions
|
@ -64,6 +64,12 @@ class Registrar::SessionsController < Devise::SessionsController
|
||||||
# rubocop:enable Metrics/MethodLength
|
# rubocop:enable Metrics/MethodLength
|
||||||
# rubocop:enable Metrics/AbcSize
|
# rubocop:enable Metrics/AbcSize
|
||||||
|
|
||||||
|
def switch_user
|
||||||
|
@api_user = ApiUser.find(params[:id])
|
||||||
|
sign_in @api_user if @api_user.identity_code == current_user.identity_code
|
||||||
|
redirect_to :back
|
||||||
|
end
|
||||||
|
|
||||||
def id
|
def id
|
||||||
@user = ApiUser.find_by_idc_data(request.env['SSL_CLIENT_S_DN'])
|
@user = ApiUser.find_by_idc_data(request.env['SSL_CLIENT_S_DN'])
|
||||||
|
|
||||||
|
|
|
@ -49,8 +49,15 @@
|
||||||
%li{class: active_class}= link_to t(:xml_console), registrar_xml_console_path
|
%li{class: active_class}= link_to t(:xml_console), registrar_xml_console_path
|
||||||
|
|
||||||
%ul.nav.navbar-nav.navbar-right
|
%ul.nav.navbar-nav.navbar-right
|
||||||
|
%li.dropdown
|
||||||
|
%a.dropdown-toggle{"data-toggle" => "dropdown", href: "#"}
|
||||||
|
= "#{current_user} (#{current_user.roles.first}) - #{current_user.registrar}"
|
||||||
|
%span.caret
|
||||||
|
%ul.dropdown-menu{role: "menu"}
|
||||||
|
- ApiUser.where(identity_code: current_user.identity_code).includes(:registrar).each do |x|
|
||||||
|
%li= link_to "#{x} (#{x.roles.first}) - #{x.registrar}", "/registrar/switch_user/#{x.id}"
|
||||||
- if user_signed_in?
|
- if user_signed_in?
|
||||||
%li= link_to t(:log_out, user: current_user), '/registrar/logout'
|
%li= link_to t(:log_out_), '/registrar/logout'
|
||||||
|
|
||||||
.container
|
.container
|
||||||
= render 'shared/flash'
|
= render 'shared/flash'
|
||||||
|
|
|
@ -555,7 +555,6 @@ en:
|
||||||
username: 'Username'
|
username: 'Username'
|
||||||
password: 'Password'
|
password: 'Password'
|
||||||
log_in: 'Log in'
|
log_in: 'Log in'
|
||||||
log_out: 'Log out (%{user})'
|
|
||||||
domains: 'Domains'
|
domains: 'Domains'
|
||||||
register: 'Register'
|
register: 'Register'
|
||||||
check: 'Check'
|
check: 'Check'
|
||||||
|
@ -879,3 +878,4 @@ en:
|
||||||
notes: Notes
|
notes: Notes
|
||||||
active_price_for_this_operation_is: 'Active price for this operation is %{price}'
|
active_price_for_this_operation_is: 'Active price for this operation is %{price}'
|
||||||
active_price_missing_for_this_operation: 'Active price missing for this operation!'
|
active_price_missing_for_this_operation: 'Active price missing for this operation!'
|
||||||
|
log_out_: 'Log out'
|
||||||
|
|
|
@ -41,6 +41,7 @@ Rails.application.routes.draw do
|
||||||
post 'sessions' => 'sessions#create'
|
post 'sessions' => 'sessions#create'
|
||||||
post 'id' => 'sessions#id'
|
post 'id' => 'sessions#id'
|
||||||
post 'mid' => 'sessions#mid'
|
post 'mid' => 'sessions#mid'
|
||||||
|
get 'switch_user/:id' => 'sessions#switch_user'
|
||||||
get 'logout' => '/devise/sessions#destroy'
|
get 'logout' => '/devise/sessions#destroy'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -39,5 +39,21 @@ feature 'Domains', type: :feature do
|
||||||
visit '/registrar/domains/new'
|
visit '/registrar/domains/new'
|
||||||
current_path.should == '/registrar/domains/new'
|
current_path.should == '/registrar/domains/new'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should switch user' do
|
||||||
|
d1 = Fabricate(:domain, registrar: @user.registrar)
|
||||||
|
user2 = Fabricate(:api_user, identity_code: @user.identity_code)
|
||||||
|
d2 = Fabricate(:domain, registrar: user2.registrar)
|
||||||
|
|
||||||
|
visit '/registrar/domains'
|
||||||
|
|
||||||
|
page.should have_text(d1.name)
|
||||||
|
page.should_not have_text(d2.name)
|
||||||
|
|
||||||
|
click_link "#{user2} (#{user2.roles.first}) - #{user2.registrar}"
|
||||||
|
|
||||||
|
page.should_not have_text(d1.name)
|
||||||
|
page.should have_text(d2.name)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue