Sha256: cd3c4266bd281a8be03f9b4d80e37855b1b1627fcf9d7c379164615c1233da15

Contents?: true

Size: 1.63 KB

Versions: 5

Compression:

Stored size: 1.63 KB

Contents

# - - - - - - - - - - - - - - - - - - - -
# DEVISE MONKEY PATCH
# - - - - - - - - - - - - - - - - - - - -
# -  https://github.com/plataformatec/devise/issues/4127#issuecomment-309010663
# -  https://github.com/plataformatec/devise/blob/88724e10adaf9ffd1d8dbfbaadda2b9d40de756a/lib/devise/controllers/helpers.rb#L110-L130
# -  https://github.com/plataformatec/devise/blob/cbbe932ee22947fb7fc741a4da3e6783091c88b0/lib/devise/failure_app.rb#L157
# -  https://github.com/plataformatec/devise/commit/cbbe932ee22947fb7fc741a4da3e6783091c88b0

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

    def scope_url
      opts  = {}

      # Initialize script_name with nil to prevent infinite loops in
      # authenticated mounted engines in rails 4.2 and 5.0
      opts[:script_name] = nil

      route = route(scope)

      opts[:format] = request_format unless skip_format?

      config = Rails.application.config

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

      router_name = Devise.mappings[scope].router_name || Devise.available_router_name

      context = send(router_name)

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
binda-0.0.7 config/initializers/devise_patch.rb
binda-0.0.6 config/initializers/devise_patch.rb
binda-0.0.5 config/initializers/devise_patch.rb
binda-0.0.3 config/initializers/devise_patch.rb
binda-0.0.2 config/initializers/devise_patch.rb