Some checks failed
continuous-integration/drone/push Build is failing
No need to keep them in two places at the same time. We can fetch them from LDAP whenever we want to do something with them.
38 lines
898 B
Ruby
38 lines
898 B
Ruby
class Admin::UsersController < Admin::BaseController
|
|
before_action :set_user, only: [:show]
|
|
before_action :set_current_section
|
|
|
|
def index
|
|
ldap = LdapService.new
|
|
@ou = params[:ou] || Setting.primary_domain
|
|
@orgs = ldap.fetch_organizations
|
|
@pagy, @users = pagy(User.where(ou: @ou).order(cn: :asc))
|
|
|
|
@stats = {
|
|
users_confirmed: User.where(ou: @ou).confirmed.count,
|
|
users_pending: User.where(ou: @ou).pending.count
|
|
}
|
|
end
|
|
|
|
def show
|
|
if Setting.lndhub_admin_enabled?
|
|
@lndhub_user = @user.lndhub_user
|
|
end
|
|
|
|
@services_enabled = @user.services_enabled
|
|
|
|
@avatar = LdapManager::FetchAvatar.call(cn: @user.cn, ou: @user.ou)
|
|
end
|
|
|
|
private
|
|
|
|
def set_user
|
|
address = params[:address].split("@")
|
|
@user = User.where(cn: address.first, ou: address.last).first
|
|
end
|
|
|
|
def set_current_section
|
|
@current_section = :users
|
|
end
|
|
end
|