aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/api/v1/iboo_controller.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/app/controllers/api/v1/iboo_controller.rb b/app/controllers/api/v1/iboo_controller.rb
new file mode 100644
index 000000000..d1633560f
--- /dev/null
+++ b/app/controllers/api/v1/iboo_controller.rb
@@ -0,0 +1,24 @@
+class Api::V1::IbooController < Api::V1::ChouetteController
+ protected
+ def begin_of_association_chain
+ @current_organisation
+ end
+
+ private
+ def authenticate
+ authenticate_with_http_basic do |login, token|
+ api_key = Api::V1::ApiKey.find_by(token: token)
+ user = User.find_by(username: login)
+
+ return unless api_key && user
+ if api_key.organisation == user.organisation
+ @current_user = user
+ @current_organisation = user.organisation
+ end
+ end
+
+ unless @current_user && @current_organisation
+ request_http_basic_authentication
+ end
+ end
+end