Class: Decidim::Authorization

Inherits:
ApplicationRecord show all
Defined in:
app/models/decidim/authorization.rb

Overview

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.

Instance Method Summary collapse

Instance Method Details

#grant!Object



24
25
26
27
28
# File 'app/models/decidim/authorization.rb', line 24

def grant!
  remove_verification_attachment!

  update!(granted_at: Time.zone.now, verification_metadata: {})
end

#granted?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'app/models/decidim/authorization.rb', line 30

def granted?
  !granted_at.nil?
end