Sha256: 30e37957eebc38705808558e910b3779ea9bb9bd545f1ec2af9f4806d6195ef8

Contents?: true

Size: 1.34 KB

Versions: 8

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literal: true

module Devise
  module Controllers
    # Custom Responder to configure default statuses that only apply to Devise,
    # and allow to integrate more easily with Hotwire/Turbo.
    class Responder < ActionController::Responder
      if respond_to?(:error_status=) && respond_to?(:redirect_status=)
        self.error_status = :ok
        self.redirect_status = :found
      else
        # TODO: remove this support for older Rails versions, which aren't supported by Turbo
        # and/or responders. It won't allow configuring a custom response, but it allows Devise
        # to use these methods and defaults across the implementation more easily.
        def self.error_status
          :ok
        end

        def self.redirect_status
          :found
        end

        def self.error_status=(*)
          warn "[DEVISE] Setting the error status on the Devise responder has no effect with this " \
            "version of `responders`, please make sure you're using a newer version. Check the changelog for more info."
        end

        def self.redirect_status=(*)
          warn "[DEVISE] Setting the redirect status on the Devise responder has no effect with this " \
            "version of `responders`, please make sure you're using a newer version. Check the changelog for more info."
        end
      end
    end
  end
end

Version data entries

8 entries across 7 versions & 3 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.1.0/gems/devise-4.9.4/lib/devise/controllers/responder.rb
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/devise-4.9.4/lib/devise/controllers/responder.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/devise-4.9.4/lib/devise/controllers/responder.rb
devise-4.9.4 lib/devise/controllers/responder.rb
devise-4.9.3 lib/devise/controllers/responder.rb
devise-4.9.2 lib/devise/controllers/responder.rb
devise-4.9.1 lib/devise/controllers/responder.rb
devise-4.9.0 lib/devise/controllers/responder.rb