commit
d83ce60516
8 changed files with 37 additions and 14 deletions
|
@ -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
|
||||
|
|
|
@ -32,11 +32,22 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
private
|
||||
|
||||
def login(user)
|
||||
session[:user_id] = user.id
|
||||
session[:scope] = FoodsoftConfig.scope # Save scope in session to not allow switching between foodcoops with one account
|
||||
session[:locale] = user.locale
|
||||
end
|
||||
|
||||
def logout
|
||||
session[:user_id] = nil
|
||||
session[:return_to] = nil
|
||||
end
|
||||
|
||||
def authenticate(role = 'any')
|
||||
# Attempt to retrieve authenticated user from controller instance or session...
|
||||
if !current_user
|
||||
# No user at all: redirect to login page.
|
||||
session[:user_id] = nil
|
||||
logout
|
||||
session[:return_to] = request.original_url
|
||||
redirect_to_login :alert => I18n.t('application.controller.error_authn')
|
||||
else
|
||||
|
|
|
@ -9,10 +9,7 @@ class SessionsController < ApplicationController
|
|||
def create
|
||||
user = User.authenticate(params[:nick], params[:password])
|
||||
if user
|
||||
session[:user_id] = user.id
|
||||
session[:scope] = FoodsoftConfig.scope # Save scope in session to not allow switching between foodcoops with one account
|
||||
session[:locale] = user.locale
|
||||
|
||||
login user
|
||||
if session[:return_to].present?
|
||||
redirect_to_url = session[:return_to]
|
||||
session[:return_to] = nil
|
||||
|
@ -27,8 +24,7 @@ class SessionsController < ApplicationController
|
|||
end
|
||||
|
||||
def destroy
|
||||
session[:user_id] = nil
|
||||
session[:return_to] = nil
|
||||
logout
|
||||
redirect_to login_url, :notice => I18n.t('sessions.logged_out')
|
||||
end
|
||||
|
||||
|
|
|
@ -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)}
|
||||
|
|
|
@ -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}'
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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}'
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue