]> git.openstreetmap.org Git - rails.git/blob - config/initializers/oauth.rb
Localisation updates from https://translatewiki.net.
[rails.git] / config / initializers / oauth.rb
1 require "oauth/controllers/provider_controller"
2 require "oauth/rack/oauth_filter"
3
4 Rails.configuration.middleware.use OAuth::Rack::OAuthFilter
5
6 module OAuth
7   module RequestProxy
8     class RackRequest
9       def method
10         request.request_method
11       end
12     end
13   end
14 end
15
16 module OpenStreetMap
17   module ProviderController
18     def self.prepended(mod)
19       mod.singleton_class.prepend(OpenStreetMap::ProviderController::ClassMethods)
20     end
21
22     def render(options = {})
23       text = options.delete(:text)
24       if text
25         super options.merge(:plain => text)
26       elsif options.delete(:nothing)
27         status = options.delete(:status) || :ok
28         head status, options
29       else
30         super options
31       end
32     end
33
34     module ClassMethods
35       def included(controller)
36         controller.class_eval do
37           def self.before_filter(*names, &blk)
38             before_action(*names, &blk)
39           end
40
41           def self.skip_before_filter(*names, &blk)
42             skip_before_action(*names, &blk)
43           end
44         end
45
46         super controller
47       end
48     end
49   end
50 end
51
52 OAuth::Controllers::ProviderController.prepend(OpenStreetMap::ProviderController)