Sha256: 6da4d4f8ae067eb196f04bd01917777baa5c2797f5a9bb2bf67c912ccdb3fa97

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

require "action_controller/metal"

module Devise
  # Failure application that will be called every time :warden is thrown from
  # any strategy or hook. Responsible for redirect the user to the sign in
  # page based on current scope and mapping. If no scope is given, redirect
  # to the default_url.
  class FailureApp < ActionController::Metal

    protected

    # Monkey patching to unset opts[:script_name]
    # See https://github.com/plataformatec/devise/issues/4127
    def scope_url
      opts  = {}
      route = route(scope)
      opts[:format] = request_format unless skip_format?

      config = Rails.application.config

      # Monkey Patch
      if config.respond_to?(:relative_url_root) && config.relative_url_root.present?
        opts[:script_name] = config.relative_url_root
      end
      # EO Monkey Patch

      router_name = Devise.mappings[scope].router_name || Devise.available_router_name
      context = send(router_name)

      if context.respond_to?(route)
        context.send(route, opts)
      elsif respond_to?(:root_url)
        root_url(opts)
      else
        "/"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mno-enterprise-api-3.4.0 config/initializers/devise_patch.rb
mno-enterprise-api-3.3.3 config/initializers/devise_patch.rb