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

@ -6,7 +6,8 @@ class Admin::UsersController < Admin::BaseController
ldap = LdapService.new
@ou = params[:ou] || "kosmos.org"
@orgs = ldap.fetch_organizations
@entries = ldap.fetch_users(ou: @ou)
@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

View File

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