Class: ExampleAuthorizationHandler

Inherits:
Decidim::AuthorizationHandler
  • Object
show all
Defined in:
lib/generators/decidim/templates/authorization_handler.rb

Overview

An example authorization handler used so that users can be verified against third party systems.

You should probably rename this class and file to match your needs.

If you need a custom form to be rendered, you can create a file matching the class name named “_form”.

Example:

A handler named Decidim::CensusHandler would look for its partial in:
decidim/census/form

When testing your authorization handler, add this line to be sure it has a valid public api:

it_behaves_like "an authorization handler"

See Decidim::AuthorizationHandler for more documentation.

Instance Method Summary collapse

Instance Method Details

#valid?Boolean

The only method that needs to be implemented for an authorization handler. Here you can add your business logic to check if the authorization should be created or not, you should return a Boolean value.

Note that if you set some validations and overwrite this method, then the validations will not run, so it’s easier to just remove this method and reite your logic using ActiveModel validations.

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


42
43
44
# File 'lib/generators/decidim/templates/authorization_handler.rb', line 42

def valid?
  raise NotImplementedError
end