Sha256: e2adac3036f541e767d88900872b4da2c4c346153a6cc4128786a7503d5d3c34

Contents?: true

Size: 1.99 KB

Versions: 13

Compression:

Stored size: 1.99 KB

Contents

require 'devise'

module ActiveAdmin
  module Devise

    def self.config
      config = {
        :path => ActiveAdmin.application.default_namespace,
        :controllers => ActiveAdmin::Devise.controllers,
        :path_names => { :sign_in => 'login', :sign_out => "logout" }
      }

      if ::Devise.respond_to?(:sign_out_via)
        logout_methods = [::Devise.sign_out_via, ActiveAdmin.application.logout_link_method].flatten.uniq
        config.merge!( :sign_out_via => logout_methods)
      end

      config
    end

    def self.controllers
      {
        :sessions => "active_admin/devise/sessions",
        :passwords => "active_admin/devise/passwords",
        :unlocks => "active_admin/devise/unlocks"
      }
    end

    module Controller
      extend ::ActiveSupport::Concern
      included do
        layout 'active_admin_logged_out'
        helper ::ActiveAdmin::ViewHelpers
      end

      # Redirect to the default namespace on logout
      def root_path
        namespace = ActiveAdmin.application.default_namespace.presence
        root_path_method = [namespace, :root_path].compact.join('_')

        url_helpers = Rails.application.routes.url_helpers

        path = if url_helpers.respond_to? root_path_method
                 url_helpers.send root_path_method
               else
                 # Guess a root_path when url_helpers not helpful
                 "/#{namespace}"
               end

        # NOTE: `relative_url_root` is deprecated by rails.
        #       Remove prefix here if it is removed completely.
        prefix = Rails.configuration.action_controller[:relative_url_root] || ''
        prefix + path
      end
    end

    class SessionsController < ::Devise::SessionsController
      include ::ActiveAdmin::Devise::Controller
    end

    class PasswordsController < ::Devise::PasswordsController
      include ::ActiveAdmin::Devise::Controller
    end

    class UnlocksController < ::Devise::UnlocksController
      include ::ActiveAdmin::Devise::Controller
    end

  end
end

Version data entries

13 entries across 13 versions & 3 rubygems

Version Path
activeadmin-0.6.6 lib/active_admin/devise.rb
activeadmin-0.6.5 lib/active_admin/devise.rb
activeadmin-0.6.4 lib/active_admin/devise.rb
yousty-activeadmin-1.0.4.pre lib/active_admin/devise.rb
yousty-activeadmin-1.0.3.pre lib/active_admin/devise.rb
yousty-activeadmin-1.0.2.pre lib/active_admin/devise.rb
activeadmin-0.6.3 lib/active_admin/devise.rb
yousty-activeadmin-1.0.1.pre lib/active_admin/devise.rb
yousty-activeadmin-1.0.0.pre lib/active_admin/devise.rb
activeadmin-0.6.2 lib/active_admin/devise.rb
activeadmin-0.6.1 lib/active_admin/devise.rb
aa-rails4-0.6.0 lib/active_admin/devise.rb
activeadmin-0.6.0 lib/active_admin/devise.rb