diff --git a/Gemfile.lock b/Gemfile.lock index 3bcf035923a1b66be17b1c1c0a6f72c275582944..c54b73d986c70e08524e08b035a6ff96db61b261 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -59,7 +59,7 @@ PATH activerecord faraday jwt (>= 0.1.3) - oauth2 + oauth2 (= 0.4.1) sinatra GEM diff --git a/app/controllers/authorizations_controller.rb b/app/controllers/authorizations_controller.rb index b8153eb4564374474a13cd3bf43c658a0a8671b1..12faaf9bc1d5042540b0412a9932c23148c534cc 100644 --- a/app/controllers/authorizations_controller.rb +++ b/app/controllers/authorizations_controller.rb @@ -12,9 +12,10 @@ class AuthorizationsController < ApplicationController @requested_scopes = params["scope"].split(',') @client = oauth2_authorization_request.client - if current_user.applications.present? - tokens = current_user.authorizations.first.access_tokens.first - redirect_to "#{params[:redirect_uri]}&access_token=#{tokens.access_token}&refresh_token=#{tokens.refresh_token}" + if authorization = current_user.authorizations.where(:client_id => @client.id).first + ac = authorization.authorization_codes.create(:redirect_uri => params[:redirect_uri]) + #tokens = current_user.authorizations.first.access_tokens.first + redirect_to "#{params[:redirect_uri]}&code=#{ac.code}" end end diff --git a/features/oauth.feature b/features/oauth.feature index 92dba9a7308b9dea46c819310830689b2a99f116..ff4470ea6a0e8cbf7e19e9555d5e673e95c98443 100644 --- a/features/oauth.feature +++ b/features/oauth.feature @@ -100,6 +100,7 @@ Feature: oauth And I fill in my Diaspora ID to connect And I press "Connect to Diaspora" + And I debug Then I should be on "/account" on Chubbies And I should have 1 user on Chubbies diff --git a/features/step_definitions/oauth_steps.rb b/features/step_definitions/oauth_steps.rb index 1a50afb691721c004aa15af95e2273e36b480241..07cfda4cfe5af67aee6d13e7d7587120e4477415 100644 --- a/features/step_definitions/oauth_steps.rb +++ b/features/step_definitions/oauth_steps.rb @@ -80,7 +80,7 @@ class Chubbies end def self.nullify - "2> /dev/null > /dev/null" + # "2> /dev/null > /dev/null" end def self.kill diff --git a/spec/chubbies/app.rb b/spec/chubbies/app.rb index 399d024cb799666bfaf209c388758a65def7dd88..204cb815f05b93c205af498e6d23a5b00e5e02c3 100644 --- a/spec/chubbies/app.rb +++ b/spec/chubbies/app.rb @@ -75,8 +75,8 @@ module Chubbies def account_const User end - def create_account(*args) - account_const.create(args) + def create_account(hash) + account_const.create(hash) end get '/account' do