diff options
| author | Xinhui | 2017-08-22 12:48:54 +0200 |
|---|---|---|
| committer | Xinhui | 2017-08-22 14:52:49 +0200 |
| commit | 49eeb2919090f26f5d16d446df6f5890fc71625a (patch) | |
| tree | a2d25a9a625ea836b0958041303d09b65ea92972 /app/controllers | |
| parent | 857ff70a1fead6e29fb372f830710655d44cb3cc (diff) | |
| download | chouette-core-49eeb2919090f26f5d16d446df6f5890fc71625a.tar.bz2 | |
API - Iboo controller for basic auth end points
Diffstat (limited to 'app/controllers')
| -rw-r--r-- | app/controllers/api/v1/iboo_controller.rb | 24 |
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 |
