Sha256: c462376fcdd76759435078f16ebede39f10e4c293ba1e6684fd68c134a567cbf

Contents?: true

Size: 814 Bytes

Versions: 1

Compression:

Stored size: 814 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_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

1 entries across 1 versions & 1 rubygems

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