Sha256: af5b2386b9ab7ec9b8b10d574b7fb74320977ba6610e910dfc7063b9f41f81c8

Contents?: true

Size: 981 Bytes

Versions: 16

Compression:

Stored size: 981 Bytes

Contents

require 'devise/doorkeeper/version'
require 'devise/strategies/doorkeeper'
require 'devise/doorkeeper/doorkeeper_failure_app'

module Devise
  module Doorkeeper
    # configure devise to support doorkeeper error responses
    def self.configure_devise(config)
      Devise::FailureApp.prepend(Devise::Doorkeeper::DoorkeeperFailureApp)
    end

    # configure doorkeeper to use devise authentication
    def self.configure_doorkeeper(base)
      base.instance_eval do
        resource_owner_authenticator do
          current_user || warden.authenticate!(scope: :user)
        end

        # configure doorkeeper to use devise database authenticatable plugin
        resource_owner_from_credentials do
          user = User.find_for_database_authentication(email: params[:username])
          if user && user.valid_for_authentication? { user.valid_password?(params[:password]) }
            user
          else
            nil
          end
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
devise-doorkeeper-1.2.0.ci.137.1 lib/devise/doorkeeper.rb
devise-doorkeeper-1.2.0 lib/devise/doorkeeper.rb
devise-doorkeeper-1.2.0.ci.133.1 lib/devise/doorkeeper.rb
devise-doorkeeper-1.1.2.ci.129.1 lib/devise/doorkeeper.rb
devise-doorkeeper-1.1.2.ci.123.1 lib/devise/doorkeeper.rb
devise-doorkeeper-1.1.2.ci.118.1 lib/devise/doorkeeper.rb
devise-doorkeeper-1.1.2.ci.112.1 lib/devise/doorkeeper.rb
devise-doorkeeper-1.1.2.ci.103.1 lib/devise/doorkeeper.rb
devise-doorkeeper-1.1.2.ci.96.1 lib/devise/doorkeeper.rb
devise-doorkeeper-1.1.2.ci.89.1 lib/devise/doorkeeper.rb
devise-doorkeeper-1.1.2.ci.62.1 lib/devise/doorkeeper.rb
devise-doorkeeper-1.1.2.ci.59.1 lib/devise/doorkeeper.rb
devise-doorkeeper-1.1.2.ci.45.1 lib/devise/doorkeeper.rb
devise-doorkeeper-1.1.2.ci.33.1 lib/devise/doorkeeper.rb
devise-doorkeeper-1.1.2.ci.30.1 lib/devise/doorkeeper.rb
devise-doorkeeper-1.1.2 lib/devise/doorkeeper.rb