Switch user in registrar #2754

This commit is contained in:
Martin Lensment 2015-07-28 17:56:01 +03:00
parent 0c4e152abd
commit 0a0543c715
5 changed files with 32 additions and 2 deletions

View file

@ -64,6 +64,12 @@ class Registrar::SessionsController < Devise::SessionsController
# rubocop:enable Metrics/MethodLength
# 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
@user = ApiUser.find_by_idc_data(request.env['SSL_CLIENT_S_DN'])

View file

@ -49,8 +49,15 @@
%li{class: active_class}= link_to t(:xml_console), registrar_xml_console_path
%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?
%li= link_to t(:log_out, user: current_user), '/registrar/logout'
%li= link_to t(:log_out_), '/registrar/logout'
.container
= render 'shared/flash'