From 8747ce4eb018fcb49c193883241f7cfe14daeaf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Sat, 10 Feb 2024 08:54:28 +0100 Subject: [PATCH] Remove multi-domain support on admin user pages refs #166 --- app/controllers/admin/users_controller.rb | 7 +++---- app/views/admin/users/index.html.erb | 18 ++---------------- app/views/admin/users/show.html.erb | 2 +- config/routes.rb | 7 ++++++- 4 files changed, 12 insertions(+), 22 deletions(-) diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index db5da30..1849fa6 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -4,8 +4,7 @@ class Admin::UsersController < Admin::BaseController def index ldap = LdapService.new - @ou = params[:ou] || Setting.primary_domain - @orgs = ldap.fetch_organizations + @ou = Setting.primary_domain @pagy, @users = pagy(User.where(ou: @ou).order(cn: :asc)) @stats = { @@ -27,8 +26,8 @@ class Admin::UsersController < Admin::BaseController private def set_user - address = params[:address].split("@") - @user = User.where(cn: address.first, ou: address.last).first + @user = User.find_by(cn: params[:username], ou: Setting.primary_domain) + http_status :not_found unless @user end def set_current_section diff --git a/app/views/admin/users/index.html.erb b/app/views/admin/users/index.html.erb index e0eb90d..830057a 100644 --- a/app/views/admin/users/index.html.erb +++ b/app/views/admin/users/index.html.erb @@ -1,4 +1,4 @@ -<%= render HeaderComponent.new(title: "Users: #{@ou}") %> +<%= render HeaderComponent.new(title: "Users") %> <%= render MainSimpleComponent.new do %>
@@ -16,19 +16,6 @@ <% end %>
- <% if @orgs.length > 1 %> -
- - -
- <% end %> -
@@ -36,13 +23,12 @@ - <% @users.each do |user| %> - + diff --git a/app/views/admin/users/show.html.erb b/app/views/admin/users/show.html.erb index dc904fd..0003172 100644 --- a/app/views/admin/users/show.html.erb +++ b/app/views/admin/users/show.html.erb @@ -1,4 +1,4 @@ -<%= render HeaderComponent.new(title: "User: #{@user.address}") %> +<%= render HeaderComponent.new(title: "User: #{@user.cn}") %> <%= render MainSimpleComponent.new do %>
diff --git a/config/routes.rb b/config/routes.rb index 643b095..8dee02d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -73,9 +73,14 @@ Rails.application.routes.draw do namespace :admin do root to: 'dashboard#index' - resources 'users', param: 'address', only: ['index', 'show'], constraints: { address: /.*/ } + resources 'users', param: 'username', only: ['index', 'show'] do + + end + get 'invitations', to: 'invitations#index' + resources :donations + get 'lightning', to: 'lightning#index' namespace :app_catalog do
UID Status Roles
<%= link_to(user.cn, admin_user_path(user.address), class: 'ks-text-link') %><%= link_to(user.cn, admin_user_path(user.cn), class: 'ks-text-link') %> <%= user.confirmed_at.nil? ? badge("pending", :yellow) : "" %> <%= user.is_admin? ? badge("admin", :red) : "" %>