From a7d9bbed84d4022ce25c12190af19e06b59499b0 Mon Sep 17 00:00:00 2001 From: danielgrippi <danielgrippi@gmail.com> Date: Tue, 9 Aug 2011 18:49:07 -0700 Subject: [PATCH] wip --- Gemfile.lock | 2 +- app/controllers/authorizations_controller.rb | 7 ++++--- features/oauth.feature | 1 + features/step_definitions/oauth_steps.rb | 2 +- spec/chubbies/app.rb | 4 ++-- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 3bcf035923..c54b73d986 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 b8153eb456..12faaf9bc1 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 92dba9a730..ff4470ea6a 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 1a50afb691..07cfda4cfe 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 399d024cb7..204cb815f0 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 -- GitLab