akkounts/app/controllers/application_controller.rb
Sebastian Kippe f0312cb8e7
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.
2020-11-18 00:22:44 +01:00

23 lines
566 B
Ruby

class ApplicationController < ActionController::Base
rescue_from DeviseLdapAuthenticatable::LdapException do |exception|
render :text => exception, :status => 500
end
def require_user_signed_in
unless user_signed_in?
redirect_to welcome_path and return
end
end
def authorize_admin
http_status :forbidden unless current_user.is_admin?
end
def http_status(status)
respond_to do |format|
format.html { render template: "shared/status_#{status.to_s}", status: status }
format.any { head status }
end
end
end