ConsorciAOC-PRJ/decidim-module-trusted-ids

View on GitHub
app/models/concerns/decidim/trusted_ids/authorization_override.rb

Summary

Maintainability
A
35 mins
Test Coverage
# frozen_string_literal: true

module Decidim
  module TrustedIds
    module AuthorizationOverride
      extend ActiveSupport::Concern

      included do
        # allows to configure the expiration time with the organization config properties
        def expires_at
          return unless workflow_manifest

          expires_in = organization.trusted_ids_census_config&.expiration_days&.days&.to_i || workflow_manifest.expires_in
          return if expires_in.zero?

          (granted_at || created_at) + expires_in
        end
      end
    end
  end
end