Sha256: 631416be54d41976e9953af59ea24efb6d8c23d2a176634f5f504ebd9bc9366d

Contents?: true

Size: 735 Bytes

Versions: 1

Compression:

Stored size: 735 Bytes

Contents

module ExvoAuth::Controllers::Rails
  def self.included(base)
    base.send :include, ExvoAuth::Controllers::Base
    base.send :include, InstanceMethods
    base.helper_method :current_user, :signed_in?
  end
    
  module InstanceMethods
    def authenticate_app_in_scope!(scope)
      authenticate_or_request_with_http_basic do |consumer_id, access_token|
        @current_scopes = ExvoAuth::Autonomous::Provider.new(
          :consumer_id  => consumer_id, 
          :access_token => access_token
        ).scopes
        
        @current_scopes.include?(scope)
      end
    end

    protected
    
    def find_user_by_id(id)
      User.find(id)
    end

    def current_url
      request.url if request.get?
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
exvo-auth-0.6.1 lib/exvo_auth/controllers/rails.rb