aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/api/v1/iboo_controller.rb24
-rw-r--r--spec/controllers/api/v1/iboo_controller_spec.rb5
2 files changed, 29 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
diff --git a/spec/controllers/api/v1/iboo_controller_spec.rb b/spec/controllers/api/v1/iboo_controller_spec.rb
new file mode 100644
index 000000000..92b70711e
--- /dev/null
+++ b/spec/controllers/api/v1/iboo_controller_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe Api::V1::IbooController, type: :controller do
+
+end