Enable authorization in your application by calling active_element.authenticate_with
and active_element.authorize_with
from a prepend_before_action
. For example, if you are using Devise:
# app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
prepend_before_action :configure_authentication
private
def configure_authentication
active_element.authenticate_with { authenticate_user! }
active_element.authorize_with { current_user }
end
end
Adjust the provided example to suit your application’s authentication framework.
As long as the following conditions are met then your application is ready to use ActiveElement’s authorization system:
active_element.authenticate_with
renders or redirects on authentication failure.active_element.authorize_with
returns an object that implements a #permissions
method which returns an array of strings.