aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/api
diff options
context:
space:
mode:
authorXinhui2017-08-22 14:42:26 +0200
committerXinhui2017-08-22 14:52:49 +0200
commit7c0d5f726634531e489db59695cb16df353ea975 (patch)
treec50cba5d48042374c49f3c4670b769e622eba4ed /app/controllers/api
parente44b43ba2d6aeab84a2aead6e01aa9cd71c2d6e5 (diff)
downloadchouette-core-7c0d5f726634531e489db59695cb16df353ea975.tar.bz2
API - Refactoring iboo controller basic auth username should be an organisation code
Diffstat (limited to 'app/controllers/api')
-rw-r--r--app/controllers/api/v1/iboo_controller.rb14
1 files changed, 7 insertions, 7 deletions
diff --git a/app/controllers/api/v1/iboo_controller.rb b/app/controllers/api/v1/iboo_controller.rb
index d1633560f..7ea4cc22e 100644
--- a/app/controllers/api/v1/iboo_controller.rb
+++ b/app/controllers/api/v1/iboo_controller.rb
@@ -6,18 +6,18 @@ class Api::V1::IbooController < Api::V1::ChouetteController
private
def authenticate
- authenticate_with_http_basic do |login, token|
+ authenticate_with_http_basic do |code, token|
api_key = Api::V1::ApiKey.find_by(token: token)
- user = User.find_by(username: login)
+ organisation = Organisation.find_by(code: code)
- return unless api_key && user
- if api_key.organisation == user.organisation
- @current_user = user
- @current_organisation = user.organisation
+ return unless api_key && organisation
+
+ if api_key.organisation == organisation
+ @current_organisation = organisation
end
end
- unless @current_user && @current_organisation
+ unless @current_organisation
request_http_basic_authentication
end
end