Sha256: 1b221eef2aa02ffc0813ae53158dd0bb39eb402f3041679334649dd43cd55a66

Contents?: true

Size: 856 Bytes

Versions: 3

Compression:

Stored size: 856 Bytes

Contents

module ExvoAuth::Controllers::Merb
  def self.included(base)
    base.send :include, ExvoAuth::Controllers::Base
    base.send :include, InstanceMethods
  end
  
  module InstanceMethods
    def authenticate_user!
      super
      throw :halt unless signed_in?
    end

    def authenticate_app_in_scope!(scope)    
      basic_authentication 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 redirect_to(*args)
      redirect(*args)
    end
    
    def find_user_by_id(id)
      User[id]
    end

    def current_url
      request.full_uri if request.method == :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/merb.rb
exvo-auth-0.7.0 lib/exvo_auth/controllers/merb.rb
exvo-auth-0.6.2 lib/exvo_auth/controllers/merb.rb