Module: Doorkeeper::Helpers::Filter::ClassMethods

Defined in:
lib/doorkeeper/helpers/filter.rb

Instance Method Summary collapse

Instance Method Details

#doorkeeper_for(*args) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/doorkeeper/helpers/filter.rb', line 5

def doorkeeper_for(*args)
  doorkeeper_for = DoorkeeperForBuilder.create_doorkeeper_for(*args)

  before_filter doorkeeper_for.filter_options do
    return if doorkeeper_for.validate_token(doorkeeper_token)
    # TODO: use ErrorRespose class for this
    render_options = doorkeeper_unauthorized_render_options
    if render_options.nil? || render_options.empty?
      head :unauthorized
    else
      render_options[:status] = :unauthorized
      render_options[:layout] = false if render_options[:layout].nil?
      render render_options
    end
  end
end