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)
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

View file

@ -35,5 +35,7 @@
%hr/
%p
= 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)},
:method => :delete, class: 'btn btn-danger'
= link_to t('ui.delete'), [:admin, @user], 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}
search_placeholder: name ..
users:
controller:
sudo_done: You are now logged in as %{user}. Be careful, and do not forget to log out when done!
edit:
title: Edit user
index:
@ -277,12 +279,14 @@ en:
new:
title: Create new user
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
member_since: Member since %{time}
person: Person
preference: Preferences
send_message: Send message
sudo: Take on identity
workgroups:
destroy:
error: 'Workgroup could not be deleted: %{error}'

View file

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

View file

@ -275,12 +275,14 @@ nl:
new:
title: Nieuwe gebruiker toevoegen
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
member_since: Lid sinds %{time}
person: Persoon
preference: Voorkeuren
send_message: Bericht versturen
sudo: Inloggen als
workgroups:
destroy:
error: 'Werkgroep kon niet verwijderd worden: %{error}'

View file

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