aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/api/v1/iboo_controller.rb
blob: 4db9e9007554d0a45a01da773f68efed873521e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class Api::V1::IbooController < Api::V1::ChouetteController
  protected
  def begin_of_association_chain
    @current_organisation
  end

  private
  def authenticate
    authenticate_with_http_basic do |code, token|
      if organisation = Organisation.find_by(code: code)
        if organisation.api_keys.exists?(token: token)
          @current_organisation = organisation
        end
      end
    end

    unless @current_organisation
      request_http_basic_authentication
    end
  end
end