Class: Oauned::OauthController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Oauned::OauthController
- Defined in:
- app/controllers/oauned/oauth_controller.rb
Instance Method Summary collapse
Instance Method Details
#authorize ⇒ Object
16 17 18 19 20 |
# File 'app/controllers/oauned/oauth_controller.rb', line 16 def = client.(current_user) state_param = params[:state].blank? ? "" : "&state=#{CGI.escape(params[:state])}" redirect_to "#{params[:redirect_uri]}?code=#{.code}&expires_in=#{.expires_in}#{state_param}" end |
#index ⇒ Object
8 9 10 11 12 13 14 |
# File 'app/controllers/oauned/oauth_controller.rb', line 8 def index ## # If the application has the no_confirmation attribute set to true, we don't ask for confirmation. # See https://github.com/dmathieu/oauned/wiki/Skip-Authorization # return if client.respond_to?(:no_confirmation) && client.no_confirmation end |
#token ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/controllers/oauned/oauth_controller.rb', line 22 def token if refresh_token? original_token = Oauned::Models['connection'].where(['refresh_token LIKE ?', params[:refresh_token]]).first if original_token.nil? || original_token.application_id != client.id return render_error("Refresh token is invalid", "invalid-grant") end token = original_token.refresh else = Oauned::Models['authorization'].where(['code LIKE ?', params[:code]]).first if .nil? || .expired? || .application_id != client.id return render_error("Authorization expired or invalid", "invalid-grant") end token = .tokenize! end render :json => { :access_token => token.access_token, :refresh_token => token.refresh_token, :expired_in => token.expires_in } end |