Sha256: ef910f0237416cd4f45d35a1d6e652bf448e6c145f27baf10b7e2d9454b2b536

Contents?: true

Size: 1.69 KB

Versions: 12

Compression:

Stored size: 1.69 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?

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

      if relative_url_root?
        opts[:script_name] = relative_url_root
      elsif defined? context.routes
        rootpath = context.routes.url_helpers.root_path
        opts[:script_name] = rootpath.chomp('/') unless rootpath.length <= 1
      end

      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

12 entries across 12 versions & 1 rubygems

Version Path
binda-0.1.11 config/initializers/devise_patch.rb
binda-0.1.10 config/initializers/devise_patch.rb
binda-0.1.9 config/initializers/devise_patch.rb
binda-0.1.8 config/initializers/devise_patch.rb
binda-0.1.7 config/initializers/devise_patch.rb
binda-0.1.6 config/initializers/devise_patch.rb
binda-0.1.5 config/initializers/devise_patch.rb
binda-0.1.4 config/initializers/devise_patch.rb
binda-0.1.3 config/initializers/devise_patch.rb
binda-0.1.2 config/initializers/devise_patch.rb
binda-0.1.1 config/initializers/devise_patch.rb
binda-0.1.0 config/initializers/devise_patch.rb