Switch admin users index from pure LDAP to database

This commit is contained in:
Râu Cao 2023-02-25 15:31:19 +08:00
parent 678e80a25d
commit 8eb487600c
Signed by: raucao
GPG Key ID: 15E65F399D084BA9
2 changed files with 11 additions and 11 deletions

View File

@ -3,10 +3,11 @@ class Admin::UsersController < Admin::BaseController
before_action :set_current_section before_action :set_current_section
def index def index
ldap = LdapService.new ldap = LdapService.new
@ou = params[:ou] || "kosmos.org" @ou = params[:ou] || "kosmos.org"
@orgs = ldap.fetch_organizations @orgs = ldap.fetch_organizations
@entries = ldap.fetch_users(ou: @ou) @users = User.where(ou: @ou).order(cn: :asc).to_a
@stats = { @stats = {
users_confirmed: User.where(ou: @ou).confirmed.count, users_confirmed: User.where(ou: @ou).confirmed.count,
users_pending: User.where(ou: @ou).pending.count users_pending: User.where(ou: @ou).pending.count

View File

@ -34,18 +34,17 @@
<thead> <thead>
<tr> <tr>
<th>UID</th> <th>UID</th>
<th>E-Mail</th> <th>Status</th>
<th>Admin</th> <th>Roles</th>
<!-- <th>Password</th> --> <!-- <th>Password</th> -->
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<% @entries.each do |entry| %> <% @users.each do |user| %>
<tr> <tr>
<td><%= entry[:uid] %></td> <td><%= link_to(user.cn, admin_user_path(user.address), class: 'ks-text-link') %></td>
<td><%= entry[:mail] %></td> <td><%= user.confirmed_at.nil? ? badge("pending", :yellow) : "" %></td>
<td><%= entry[:admin] %></td> <td><%= user.is_admin? ? badge("admin", :red) : "" %></td>
<!-- <td><%= entry[:password] %></td> -->
</tr> </tr>
<% end %> <% end %>
</tbody> </tbody>