Sha256: cb73939985842e37b066463aab222c098550e2d55a205fb72c379c30322a4ec5
Contents?: true
Size: 1.01 KB
Versions: 10
Compression:
Stored size: 1.01 KB
Contents
# frozen_string_literal: true module Decidim # An authorization is a record that a User has been authorized somehow. Other # models in the system can use different kind of authorizations to allow a # user to perform actions. # # To create an authorization for a user we need to use an # AuthorizationHandler that validates the user against a set of rules. An # example could be a handler that validates a user email against an API and # depending on the response it allows the creation of the authorization or # not. class Authorization < ApplicationRecord belongs_to :user, foreign_key: "decidim_user_id", class_name: Decidim::User, inverse_of: :authorizations validates :name, :user, :handler, presence: true validates :name, uniqueness: { scope: :decidim_user_id } # The handler that created this authorization. # # Returns an instance that inherits from Decidim::AuthorizationHandler. def handler @handler ||= AuthorizationHandler.handler_for(name, metadata) end end end
Version data entries
10 entries across 10 versions & 1 rubygems