1 require 'oauth/controllers/provider_controller'
3 class OauthController < ApplicationController
4 include OAuth::Controllers::ProviderController
14 def user_authorizes_token?
17 @token.client_application.permissions.each do |pref|
19 @token.write_attribute(pref, true)
22 @token.write_attribute(pref, false)
30 @token = current_user.oauth_tokens.find_by_token params[:token]
33 flash[:notice] = t('oauth.revoke.flash', :application => @token.client_application.name)
35 redirect_to oauth_clients_url(:display_name => @token.user.display_name)
42 render :action=>"authorize_failure"
46 unless @token.invalidated?
48 if user_authorizes_token?
49 @token.authorize!(current_user)
51 callback_url = params[:oauth_callback] || @token.client_application.callback_url
53 callback_url = @token.oob? ? @token.client_application.callback_url : @token.callback_url
55 @redirect_url = URI.parse(callback_url) unless callback_url.blank?
57 unless @redirect_url.to_s.blank?
58 @redirect_url.query = @redirect_url.query.blank? ?
59 "oauth_token=#{@token.token}" :
60 @redirect_url.query + "&oauth_token=#{@token.token}"
61 unless @token.oauth10?
62 @redirect_url.query += "&oauth_verifier=#{@token.verifier}"
64 redirect_to @redirect_url.to_s
66 render :action => "authorize_success"
70 render :action => "authorize_failure"
74 render :action => "authorize_failure"