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