Authorize access to admin panel, etc.
Adds a separate admin namespace and base controller, with authorization by looking up the admin property in the user's LDAP account.
This commit is contained in:
@@ -19,4 +19,12 @@ class User < ApplicationRecord
|
||||
clear_reset_password_token if valid?
|
||||
save
|
||||
end
|
||||
|
||||
def is_admin?
|
||||
admin ||= if admin = Devise::LDAP::Adapter.get_ldap_param(self.cn, :admin)
|
||||
!!admin.first
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user