Class: DummyAuthorizationHandler

Inherits:
Decidim::AuthorizationHandler show all
Defined in:
decidim-generators/lib/decidim/generators/app_templates/dummy_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.

Direct Known Subclasses

EphemeralDummyAuthorizationHandler

Defined Under Namespace

Classes: DummyActionAuthorizer

Constant Summary

Constants included from Decidim::AttributeObject::TypeMap

Decidim::AttributeObject::TypeMap::Boolean, Decidim::AttributeObject::TypeMap::Decimal

Instance Attribute Summary

Attributes inherited from Decidim::AttributeObject::Form

#context

Instance Method Summary collapse

Methods inherited from Decidim::AuthorizationHandler

#authorization_attributes, #duplicate, #ephemeral_tos_pending?, #form_attributes, handler_for, handler_name, #handler_name, #to_partial_path, #transferrable?, #unique?, #user_transferrable?, #verification_attachment, #verification_metadata

Methods inherited from Decidim::AttributeObject::Form

ensure_hash, from_model, from_params, hash_from, infer_model_name, #map_model, mimic, mimicked_model_name, model_name, #persisted?, #to_key, #to_model, #to_param, #valid?, #with_context

Methods included from Decidim::AttributeObject::Model

#[], #[]=, #attributes, #attributes_with_values, #initialize, #to_h

Instance Method Details

#metadataObject

If you need to store any of the defined attributes in the authorization you can do it here.

You must return a Hash that will be serialized to the authorization when it is created, and available though authorization.metadata



63
64
65
# File 'decidim-generators/lib/decidim/generators/app_templates/dummy_authorization_handler.rb', line 63

def 
  super.merge(document_number:, postal_code:)
end

#unique_idObject

If set, enforces the handler to validate the uniqueness of the field



53
54
55
# File 'decidim-generators/lib/decidim/generators/app_templates/dummy_authorization_handler.rb', line 53

def unique_id
  document_number
end