]> git.openstreetmap.org Git - rails.git/blob - app/controllers/oauth_controller.rb
Make OAuth work again
[rails.git] / app / controllers / oauth_controller.rb
1 require 'oauth/controllers/provider_controller'
2
3 class OauthController < ApplicationController
4   include OAuth::Controllers::ProviderController
5
6   layout 'slim'
7
8   def login_required
9     authorize_web
10     set_locale
11     require_user
12   end
13
14   def user_authorizes_token?
15     any_auth = false
16
17     @token.client_application.permissions.each do |pref|
18       if params[pref]
19         @token.write_attribute(pref, true)
20         any_auth ||= true
21       else
22         @token.write_attribute(pref, false)
23       end
24     end
25
26     any_auth
27   end
28
29   def revoke
30     @token = current_user.oauth_tokens.find_by_token params[:token]
31     if @token
32       @token.invalidate!
33       flash[:notice] = t('oauth.revoke.flash', :application => @token.client_application.name)
34     end
35     redirect_to :controller => 'oauth_clients', :action => 'index'
36   end
37 end