Sha256: 8e3e2f34ca17acb37122d73acb46fe27afa0504ca6474b23bbb182bfcee39fa0

Contents?: true

Size: 785 Bytes

Versions: 3

Compression:

Stored size: 785 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_consumer_id = consumer_id
        
        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

3 entries across 3 versions & 1 rubygems

Version Path
exvo-auth-0.7.1 lib/exvo_auth/controllers/rails.rb
exvo-auth-0.7.0 lib/exvo_auth/controllers/rails.rb
exvo-auth-0.6.2 lib/exvo_auth/controllers/rails.rb