add sudo functionality

This commit is contained in:
wvengen 2014-10-18 17:52:06 +02:00
parent 7826d2f674
commit 68d54e7e25
6 changed files with 22 additions and 6 deletions

View file

@ -9,4 +9,10 @@ class Admin::UsersController < Admin::BaseController
@users = @users.page(params[:page]).per(@per_page) @users = @users.page(params[:page]).per(@per_page)
end end
def sudo
@user = User.find(params[:id])
login @user
redirect_to root_path, notice: I18n.t('admin.users.controller.sudo_done', user: @user.name)
end
end end

View file

@ -35,5 +35,7 @@
%hr/ %hr/
%p %p
= link_to t('ui.edit'), edit_admin_user_path(@user), class: 'btn' = link_to t('ui.edit'), edit_admin_user_path(@user), class: 'btn'
= link_to t('ui.delete'), [:admin, @user], :data => {:confirm => t('.confirm', user: @user.first_name)}, = link_to t('ui.delete'), [:admin, @user], method: :delete, class: 'btn btn-danger',
:method => :delete, class: 'btn btn-danger' data: {confirm: t('.confirm_delete', user: @user.first_name)}
= link_to t('.sudo'), sudo_admin_user_path(@user), method: :post, class: 'btn',
data: {confirm: t('.confirm_sudo', user: @user.first_name)}

View file

@ -267,6 +267,8 @@ en:
title: Ordergroup %{name} title: Ordergroup %{name}
search_placeholder: name .. search_placeholder: name ..
users: users:
controller:
sudo_done: You are now logged in as %{user}. Be careful, and do not forget to log out when done!
edit: edit:
title: Edit user title: Edit user
index: index:
@ -277,12 +279,14 @@ en:
new: new:
title: Create new user title: Create new user
show: show:
confirm: Do you really want to kick out %{user}? confirm_delete: Do you really want to delete %{user}?
confirm_sudo: "If you continue, you will take on the identity of %{user}. Do not forget to log out when you're done!"
groupabos: Group subscriptions groupabos: Group subscriptions
member_since: Member since %{time} member_since: Member since %{time}
person: Person person: Person
preference: Preferences preference: Preferences
send_message: Send message send_message: Send message
sudo: Take on identity
workgroups: workgroups:
destroy: destroy:
error: 'Workgroup could not be deleted: %{error}' error: 'Workgroup could not be deleted: %{error}'

View file

@ -275,7 +275,7 @@ fr:
new: new:
title: Ajouter unE nouveLLE_eau membre title: Ajouter unE nouveLLE_eau membre
show: show:
confirm: Veux-tu vraiment expulser %{user}? confirm_delete: Veux-tu vraiment expulser %{user}?
groupabos: Participation à des équipes groupabos: Participation à des équipes
member_since: Membre depuis %{time} member_since: Membre depuis %{time}
person: Personne person: Personne

View file

@ -275,12 +275,14 @@ nl:
new: new:
title: Nieuwe gebruiker toevoegen title: Nieuwe gebruiker toevoegen
show: show:
confirm: Wil je %{user} daadwerkelijk verwijderen? confirm_delete: Wil je %{user} daadwerkelijk verwijderen?
confirm_sudo: Als je doorgaat, neem je de identiteit aan van gebruiker %{user}. Vergeet hierna niet uit te loggen!
groupabos: Groepslidmaatschappen groupabos: Groepslidmaatschappen
member_since: Lid sinds %{time} member_since: Lid sinds %{time}
person: Persoon person: Persoon
preference: Voorkeuren preference: Voorkeuren
send_message: Bericht versturen send_message: Bericht versturen
sudo: Inloggen als
workgroups: workgroups:
destroy: destroy:
error: 'Werkgroep kon niet verwijderd worden: %{error}' error: 'Werkgroep kon niet verwijderd worden: %{error}'

View file

@ -172,7 +172,9 @@ Foodsoft::Application.routes.draw do
namespace :admin do namespace :admin do
root :to => 'base#index' root :to => 'base#index'
resources :users resources :users do
post :sudo, :on => :member
end
resources :workgroups do resources :workgroups do
get :memberships, :on => :member get :memberships, :on => :member