blob: 98c2fff05f9fdfd07b933e2f8594d317709ad182 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
module Api
module V1
class ChouetteController < ActionController::Base
inherit_resources
respond_to :json, :xml
layout false
before_action :authenticate
private
def authenticate
authenticate_or_request_with_http_token do |token, options|
@referential = Api::V1::ApiKey.referential_from_token(token)
@api_key = @referential.api_keys.find_by_token(token) if @referential
switch_referential if @api_key
end
end
def switch_referential
Apartment::Tenant.switch!(@api_key.referential.slug)
end
end
end
end
|