Sha256: 626fb836685d59c0eb021e845e7d6e08b9cb8994e5fced04e2c38b5361e0ceeb

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

module Decidim
  module ActionDelegator
    module Verifications
      module Sms
        module AuthorizationsControllerOverride
          extend ActiveSupport::Concern

          included do
            def new
              enforce_permission_to :create, :authorization, authorization: authorization

              flash.now[:error] = I18n.t("decidim.action_delegator.authorizations.new.missing_phone_error") unless direct_authorization && membership_phone

              @form = Decidim::Verifications::Sms::MobilePhoneForm.new mobile_phone_number: membership_phone
            end

            private

            def direct_authorization
              @direct_authorization ||= Decidim::Authorization.find_by(
                user: current_user,
                name: "direct_verifications"
              )
            end

            def membership_phone
              return nil unless direct_authorization

              direct_authorization.metadata["membership_phone"]
            end
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
decidim-action_delegator-0.6.0 app/controllers/decidim/action_delegator/verifications/sms/authorizations_controller_override.rb
decidim-action_delegator-0.5.0 app/controllers/decidim/action_delegator/verifications/sms/authorizations_controller_override.rb
decidim-action_delegator-0.4.1 app/controllers/decidim/action_delegator/verifications/sms/authorizations_controller_override.rb
decidim-action_delegator-0.4 app/controllers/decidim/action_delegator/verifications/sms/authorizations_controller_override.rb