From 8eb487600c81b18202e91fd79808d14c966e0160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Sat, 25 Feb 2023 15:31:19 +0800 Subject: [PATCH] Switch admin users index from pure LDAP to database --- app/controllers/admin/users_controller.rb | 9 +++++---- app/views/admin/users/index.html.erb | 13 ++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index fbe0252..f408ac7 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -3,10 +3,11 @@ class Admin::UsersController < Admin::BaseController before_action :set_current_section def index - ldap = LdapService.new - @ou = params[:ou] || "kosmos.org" - @orgs = ldap.fetch_organizations - @entries = ldap.fetch_users(ou: @ou) + ldap = LdapService.new + @ou = params[:ou] || "kosmos.org" + @orgs = ldap.fetch_organizations + @users = User.where(ou: @ou).order(cn: :asc).to_a + @stats = { users_confirmed: User.where(ou: @ou).confirmed.count, users_pending: User.where(ou: @ou).pending.count diff --git a/app/views/admin/users/index.html.erb b/app/views/admin/users/index.html.erb index 8bc4db3..9e60ac7 100644 --- a/app/views/admin/users/index.html.erb +++ b/app/views/admin/users/index.html.erb @@ -34,18 +34,17 @@ UID - E-Mail - Admin + Status + Roles - <% @entries.each do |entry| %> + <% @users.each do |user| %> - <%= entry[:uid] %> - <%= entry[:mail] %> - <%= entry[:admin] %> - + <%= link_to(user.cn, admin_user_path(user.address), class: 'ks-text-link') %> + <%= user.confirmed_at.nil? ? badge("pending", :yellow) : "" %> + <%= user.is_admin? ? badge("admin", :red) : "" %> <% end %>