From 7a5fc1150586db167bcd7ccb504beb28d6ab9ea2 Mon Sep 17 00:00:00 2001 From: Ilyaaaaaaaaaaaaa Zhitomirskiy Date: Tue, 9 Aug 2011 13:47:25 -0700 Subject: [PATCH 01/11] initial cucumber step --- features/oauth.feature | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/features/oauth.feature b/features/oauth.feature index 0388b7cc0..1886e8843 100644 --- a/features/oauth.feature +++ b/features/oauth.feature @@ -77,3 +77,19 @@ Feature: oauth Then I should be on "/account" on Chubbies And I should see my "profile.birthday" And I should see my "name" + + Scenario: Login in with Chubbies when you already authorized it + Given Chubbies is registered on my pod + When I try to authorize Chubbies + When I press "Authorize" + Then I should be on "/account" on Chubbies + And I should see my "profile.birthday" + And I should see my "name" + + Then I visit "/new" on Chubbies + And I fill in "Diaspora Handle" with "#{@me.diaspora_handle}" + And I press "Connect to Diaspora" + + And I debug + Then I should be on "/account" on Chubbies + From 27049e52b59c5c748a37d4c9d1773ceecb010a18 Mon Sep 17 00:00:00 2001 From: danielgrippi Date: Tue, 9 Aug 2011 17:22:22 -0700 Subject: [PATCH 02/11] connect logic --- Gemfile | 2 +- Gemfile.lock | 21 ++++++++++---------- app/controllers/authorizations_controller.rb | 6 +++++- features/oauth.feature | 21 +++++++++++++++----- features/step_definitions/oauth_steps.rb | 12 +++++++++-- spec/chubbies/app.rb | 15 ++++++++++++-- 6 files changed, 55 insertions(+), 22 deletions(-) diff --git a/Gemfile b/Gemfile index 052aaa7bc..8b387281c 100644 --- a/Gemfile +++ b/Gemfile @@ -119,6 +119,6 @@ group :test do gem 'rspec-instafail', '>= 0.1.7', :require => false gem 'fuubar' - gem 'diaspora-client', :git => 'git://github.com/diaspora/diaspora-client.git' + gem 'diaspora-client', :path => '~/workspace/diaspora-client' #:git => 'git://github.com/diaspora/diaspora-client.git' end diff --git a/Gemfile.lock b/Gemfile.lock index 1e8a31b37..3bcf03592 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -29,17 +29,6 @@ GIT acts-as-taggable-on (2.0.6) rails (>= 3.0) -GIT - remote: git://github.com/diaspora/diaspora-client.git - revision: 9dc2c29495c7bf040ceceecdf88800f4c91f870c - specs: - diaspora-client (0.0.0) - activerecord - faraday - jwt (>= 0.1.3) - oauth2 - sinatra - GIT remote: git://github.com/iain/http_accept_language.git revision: 0b78aa7849fc90cf9e12586af162fa4c408a795d @@ -63,6 +52,16 @@ GIT jwt (0.1.3) json (>= 1.2.4) +PATH + remote: ~/workspace/diaspora-client + specs: + diaspora-client (0.0.0) + activerecord + faraday + jwt (>= 0.1.3) + oauth2 + sinatra + GEM remote: http://rubygems.org/ specs: diff --git a/app/controllers/authorizations_controller.rb b/app/controllers/authorizations_controller.rb index 902d22c0a..b8153eb45 100644 --- a/app/controllers/authorizations_controller.rb +++ b/app/controllers/authorizations_controller.rb @@ -11,7 +11,11 @@ class AuthorizationsController < ApplicationController def new @requested_scopes = params["scope"].split(',') @client = oauth2_authorization_request.client - #render :layout => "popup" if params[:popup] + + 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}" + end end def create diff --git a/features/oauth.feature b/features/oauth.feature index 1886e8843..92dba9a73 100644 --- a/features/oauth.feature +++ b/features/oauth.feature @@ -16,12 +16,21 @@ Feature: oauth And I should see my "profile.birthday" And I should see my "name" + Scenario: Signup+login (Diaspora Connect) with Chubbies + When I visit "/reset" on Chubbies + And I should have 0 user on Chubbies + And I try to authorize Chubbies + And I press "Authorize" + Then I should be on "/account" on Chubbies + + And I should have 1 user on Chubbies + Scenario: Not authorize Chubbies When I try to authorize Chubbies When I press "No" Then I should be on "/account" on Chubbies - Then I should see "No access token." + And I should have 0 user on Chubbies Scenario: Authorize Chubbies when Chubbies is already connected Given Chubbies is registered on my pod @@ -80,16 +89,18 @@ Feature: oauth Scenario: Login in with Chubbies when you already authorized it Given Chubbies is registered on my pod + And I should have 0 user on Chubbies + When I try to authorize Chubbies When I press "Authorize" Then I should be on "/account" on Chubbies - And I should see my "profile.birthday" - And I should see my "name" + And I should have 1 user on Chubbies Then I visit "/new" on Chubbies - And I fill in "Diaspora Handle" with "#{@me.diaspora_handle}" + 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 a6ebdbdbc..1a50afb69 100644 --- a/features/step_definitions/oauth_steps.rb +++ b/features/step_definitions/oauth_steps.rb @@ -35,7 +35,7 @@ When /^I try to authorize Chubbies$/ do # as we are clearing the Diaspora DB every scenario Then 'I visit "/new" on Chubbies' ### - And "I fill in \"Diaspora Handle\" with \"#{@me.diaspora_handle}\"" + And "I fill in my Diaspora ID to connect" And 'I press "Connect to Diaspora"' Then 'I should be on the new user session page' And "I fill in \"Username\" with \"#{@me.username}\"" @@ -46,8 +46,16 @@ When /^I try to authorize Chubbies$/ do And 'I should see "The best way to chub."' end -When /^I visit "([^"]+)" on Chubbies$/ do |path| +And /^I fill in my Diaspora ID to connect$/ do + And "I fill in \"Diaspora Handle\" with \"#{@me.diaspora_handle}\"" +end +And /^I should have (\d) user on Chubbies$/ do |num| + When "I visit \"/user_count\" on Chubbies" + Then "I should see \"#{num}\"" +end + +When /^I visit "([^"]+)" on Chubbies$/ do |path| former_host = Capybara.app_host Capybara.app_host = "localhost:#{Chubbies::PORT}" visit(path) diff --git a/spec/chubbies/app.rb b/spec/chubbies/app.rb index e1233408f..399d024cb 100644 --- a/spec/chubbies/app.rb +++ b/spec/chubbies/app.rb @@ -31,6 +31,7 @@ module Chubbies end add_index :access_tokens, :user_id, :unique => true create_table :users do |t| + t.string :username, :limit => 127 t.timestamps end end @@ -60,7 +61,7 @@ module Chubbies class App < DiasporaClient::App def current_user - User.first + @user = User.first end def redirect_path @@ -71,6 +72,13 @@ module Chubbies '/account?id=1' end + def account_const + User + end + def create_account(*args) + account_const.create(args) + end + get '/account' do if params['id'] && user = User.where(:id => params['id']).first if user.access_token @@ -89,7 +97,6 @@ module Chubbies end get '/new' do - @user = User.create haml :home end @@ -104,5 +111,9 @@ module Chubbies post '/register' do DiasporaClient::ResourceServer.create!(params) end + + get '/user_count' do + User.count.to_s + end end end From a7d9bbed84d4022ce25c12190af19e06b59499b0 Mon Sep 17 00:00:00 2001 From: danielgrippi Date: Tue, 9 Aug 2011 18:49:07 -0700 Subject: [PATCH 03/11] 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 3bcf03592..c54b73d98 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 b8153eb45..12faaf9bc 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 92dba9a73..ff4470ea6 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 1a50afb69..07cfda4cf 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 399d024cb..204cb815f 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 From 76b0f310205b1f84a0a7de503b087f2799e150f1 Mon Sep 17 00:00:00 2001 From: Raphael Sofaer Date: Mon, 15 Aug 2011 13:01:21 -0700 Subject: [PATCH 04/11] Fix the chubbies icon_url field, that needs to be icon path or be a url --- features/oauth.feature | 1 - spec/chubbies/app.rb | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/features/oauth.feature b/features/oauth.feature index ff4470ea6..92dba9a73 100644 --- a/features/oauth.feature +++ b/features/oauth.feature @@ -100,7 +100,6 @@ 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/spec/chubbies/app.rb b/spec/chubbies/app.rb index 204cb815f..e598333e7 100644 --- a/spec/chubbies/app.rb +++ b/spec/chubbies/app.rb @@ -51,7 +51,7 @@ module Chubbies d.manifest_field(:name, "Chubbies") d.manifest_field(:description, "The best way to chub.") - d.manifest_field(:icon_url, "#") + d.manifest_field(:icon_url, "chubbies.jpeg") d.manifest_field(:permissions_overview, "Chubbi.es wants to post photos to your stream.") From c95f80be427927c9f22a132be8af3895ead3b221 Mon Sep 17 00:00:00 2001 From: Raphael Sofaer Date: Mon, 15 Aug 2011 15:37:52 -0700 Subject: [PATCH 05/11] Re-nullify chubbies output and correctly handle diaspora_id param in create_account --- features/step_definitions/oauth_steps.rb | 2 +- spec/chubbies/app.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/features/step_definitions/oauth_steps.rb b/features/step_definitions/oauth_steps.rb index 07cfda4cf..1a50afb69 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 e598333e7..efc64b029 100644 --- a/spec/chubbies/app.rb +++ b/spec/chubbies/app.rb @@ -76,6 +76,7 @@ module Chubbies User end def create_account(hash) + hash[:username] = hash.delete(:diaspora_id) account_const.create(hash) end From 6b88a751748a1fcfe9c4273b23bb3302cae1ced0 Mon Sep 17 00:00:00 2001 From: Raphael Sofaer Date: Mon, 15 Aug 2011 17:27:58 -0700 Subject: [PATCH 06/11] Log out a user if they arrive at AuthorizationsController#new carrying the username of a different user --- app/controllers/authorizations_controller.rb | 4 +++ spec/chubbies/app.rb | 3 -- .../authorizations_controller_spec.rb | 28 +++++++++++++++++++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/app/controllers/authorizations_controller.rb b/app/controllers/authorizations_controller.rb index 12faaf9bc..7158e29dd 100644 --- a/app/controllers/authorizations_controller.rb +++ b/app/controllers/authorizations_controller.rb @@ -9,6 +9,10 @@ class AuthorizationsController < ApplicationController skip_before_filter :verify_authenticity_token, :only => :token def new + if params[:uid] && params[:uid] != current_user.username + sign_out current_user + redirect_to request.url + end @requested_scopes = params["scope"].split(',') @client = oauth2_authorization_request.client diff --git a/spec/chubbies/app.rb b/spec/chubbies/app.rb index efc64b029..0e75311d9 100644 --- a/spec/chubbies/app.rb +++ b/spec/chubbies/app.rb @@ -72,9 +72,6 @@ module Chubbies '/account?id=1' end - def account_const - User - end def create_account(hash) hash[:username] = hash.delete(:diaspora_id) account_const.create(hash) diff --git a/spec/controllers/authorizations_controller_spec.rb b/spec/controllers/authorizations_controller_spec.rb index 1458343aa..5fedf0211 100644 --- a/spec/controllers/authorizations_controller_spec.rb +++ b/spec/controllers/authorizations_controller_spec.rb @@ -31,6 +31,34 @@ describe AuthorizationsController do } end + describe '#new' do + before do + @app = Factory.create(:app, :name => "Authorized App") + @params = { + :scope => "profile", + :redirect_uri => @manifest['application_base_url'] << '/callback', + :client_id => @app.oauth_identifier, + :uid => alice.username + } + end + it 'succeeds' do + get :new, @params + response.should be_success + end + + it 'logs out the signed in user if a different username is passed' do + @params[:uid] = bob.username + get :new, @params + response.location.should include(oauth_authorize_path) + end + + it 'it succeeds if no uid is passed' do + @params[:uid] = nil + get :new, @params + response.should be_success + end + end + describe '#token' do before do packaged_manifest = {:public_key => @public_key.export, :jwt => JWT.encode(@manifest, @private_key, "RS256")}.to_json From a63d1ad4aee5dd7f94c49cfb08a71def41d061e7 Mon Sep 17 00:00:00 2001 From: Raphael Sofaer Date: Mon, 15 Aug 2011 18:35:14 -0700 Subject: [PATCH 07/11] Sign out the signed in user if a different uid is passed to AuthorizationsController#new --- app/controllers/authorizations_controller.rb | 7 ++++--- features/oauth.feature | 8 ++++++++ features/step_definitions/oauth_steps.rb | 2 +- spec/chubbies/app.rb | 2 +- spec/chubbies/views/home.haml | 6 +++--- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/app/controllers/authorizations_controller.rb b/app/controllers/authorizations_controller.rb index 7158e29dd..e15a60b3d 100644 --- a/app/controllers/authorizations_controller.rb +++ b/app/controllers/authorizations_controller.rb @@ -9,16 +9,17 @@ class AuthorizationsController < ApplicationController skip_before_filter :verify_authenticity_token, :only => :token def new - if params[:uid] && params[:uid] != current_user.username + if params[:uid].present? && params[:uid] != current_user.username sign_out current_user - redirect_to request.url + redirect_url = Addressable::URI.parse(request.url) + redirect_url.query_values = redirect_url.query_values.merge("uid" => nil) + redirect_to redirect_url.to_s end @requested_scopes = params["scope"].split(',') @client = oauth2_authorization_request.client 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 92dba9a73..beae15c23 100644 --- a/features/oauth.feature +++ b/features/oauth.feature @@ -24,6 +24,14 @@ Feature: oauth Then I should be on "/account" on Chubbies And I should have 1 user on Chubbies + + Scenario: Signing up as a user while someone else is logged into Diaspora + Given a user with username "alice" + When I sign in as "alice@alice.alice" + Then I visit "/new" on Chubbies + And I fill in "Diaspora ID" with "bob@localhost:9887" + And I press "Connect to Diaspora" + Then I should be on the new user session page Scenario: Not authorize Chubbies When I try to authorize Chubbies diff --git a/features/step_definitions/oauth_steps.rb b/features/step_definitions/oauth_steps.rb index 1a50afb69..c1f0705fd 100644 --- a/features/step_definitions/oauth_steps.rb +++ b/features/step_definitions/oauth_steps.rb @@ -47,7 +47,7 @@ When /^I try to authorize Chubbies$/ do end And /^I fill in my Diaspora ID to connect$/ do - And "I fill in \"Diaspora Handle\" with \"#{@me.diaspora_handle}\"" + And "I fill in \"Diaspora ID\" with \"#{@me.diaspora_handle}\"" end And /^I should have (\d) user on Chubbies$/ do |num| diff --git a/spec/chubbies/app.rb b/spec/chubbies/app.rb index 0e75311d9..f924f98d5 100644 --- a/spec/chubbies/app.rb +++ b/spec/chubbies/app.rb @@ -74,7 +74,7 @@ module Chubbies def create_account(hash) hash[:username] = hash.delete(:diaspora_id) - account_const.create(hash) + User.create(hash) end get '/account' do diff --git a/spec/chubbies/views/home.haml b/spec/chubbies/views/home.haml index b97443537..eb5963edc 100644 --- a/spec/chubbies/views/home.haml +++ b/spec/chubbies/views/home.haml @@ -2,7 +2,7 @@ %head %body %form{:action => '/', :id => 'login', :method => 'get'} - %label{:for => 'diaspora_handle'} - Diaspora Handle - %input{:type=>'text', :id => 'diaspora_handle', :name => 'diaspora_handle'} + %label{:for => 'diaspora_id'} + Diaspora ID + %input{:type=>'text', :id => 'diaspora_id', :name => 'diaspora_id'} %input{:type => 'submit', :value => "Connect to Diaspora" } From 89edfb7ed61d260fb4b3f7d6f01dd29c4848a150 Mon Sep 17 00:00:00 2001 From: Raphael Sofaer Date: Mon, 15 Aug 2011 18:59:16 -0700 Subject: [PATCH 08/11] WIP prefilling username on logout of user is almost there --- Gemfile | 3 ++- app/helpers/sessions_helper.rb | 6 ++++++ app/views/sessions/new.haml | 2 +- features/oauth.feature | 2 ++ 4 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 app/helpers/sessions_helper.rb diff --git a/Gemfile b/Gemfile index 8b387281c..7beaf7f36 100644 --- a/Gemfile +++ b/Gemfile @@ -119,6 +119,7 @@ group :test do gem 'rspec-instafail', '>= 0.1.7', :require => false gem 'fuubar' - gem 'diaspora-client', :path => '~/workspace/diaspora-client' #:git => 'git://github.com/diaspora/diaspora-client.git' + gem 'diaspora-client', :path => '~/workspace/diaspora-client' + #:git => 'git://github.com/diaspora/diaspora-client.git' end diff --git a/app/helpers/sessions_helper.rb b/app/helpers/sessions_helper.rb new file mode 100644 index 000000000..9f2e94b77 --- /dev/null +++ b/app/helpers/sessions_helper.rb @@ -0,0 +1,6 @@ +module SessionsHelper + def prefilled_username + uri = Addressable::URI.parse(session["user_return_to"]) + uri ? uri.query_values["uid"] : nil + end +end diff --git a/app/views/sessions/new.haml b/app/views/sessions/new.haml index de4494f1a..5da4d36db 100644 --- a/app/views/sessions/new.haml +++ b/app/views/sessions/new.haml @@ -26,7 +26,7 @@ %p = f.label :username , t('username') - = f.text_field :username, :tabindex => 1 + = f.text_field :username, :tabindex => 1 , :value => prefilled_username %br %p diff --git a/features/oauth.feature b/features/oauth.feature index beae15c23..22a3f4274 100644 --- a/features/oauth.feature +++ b/features/oauth.feature @@ -32,6 +32,8 @@ Feature: oauth And I fill in "Diaspora ID" with "bob@localhost:9887" And I press "Connect to Diaspora" Then I should be on the new user session page + And I debug + And I should see "bob" within "#user_username" Scenario: Not authorize Chubbies When I try to authorize Chubbies From dec10e3de92d4b24a2a9ca661f2c71af19274881 Mon Sep 17 00:00:00 2001 From: Raphael Sofaer Date: Tue, 16 Aug 2011 11:26:25 -0700 Subject: [PATCH 09/11] Finish setting up sesssions#new prefill when logged out by authorizationsControlelr --- app/controllers/authorizations_controller.rb | 16 +++++++++++++--- app/helpers/sessions_helper.rb | 8 ++++++-- app/views/sessions/new.haml | 2 +- features/oauth.feature | 3 +-- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/app/controllers/authorizations_controller.rb b/app/controllers/authorizations_controller.rb index e15a60b3d..30e0a174b 100644 --- a/app/controllers/authorizations_controller.rb +++ b/app/controllers/authorizations_controller.rb @@ -11,9 +11,7 @@ class AuthorizationsController < ApplicationController def new if params[:uid].present? && params[:uid] != current_user.username sign_out current_user - redirect_url = Addressable::URI.parse(request.url) - redirect_url.query_values = redirect_url.query_values.merge("uid" => nil) - redirect_to redirect_url.to_s + redirect_to url_with_prefilled_session_form end @requested_scopes = params["scope"].split(',') @client = oauth2_authorization_request.client @@ -24,6 +22,18 @@ class AuthorizationsController < ApplicationController end end + # When diaspora detects that a user is trying to authorize to an application + # as someone other than the logged in user, we want to log out current_user, + # and prefill the session form with the user that is trying to authorize + def url_with_prefilled_session_form + redirect_url = Addressable::URI.parse(request.url) + query_values = redirect_url.query_values + query_values.delete("uid") + query_values.merge!("username" => params[:uid]) + redirect_url.query_values = query_values + redirect_url.to_s + end + def create if params[:commit] == "Authorize" grant_authorization_code(current_user) diff --git a/app/helpers/sessions_helper.rb b/app/helpers/sessions_helper.rb index 9f2e94b77..a10b0402c 100644 --- a/app/helpers/sessions_helper.rb +++ b/app/helpers/sessions_helper.rb @@ -1,6 +1,10 @@ module SessionsHelper def prefilled_username - uri = Addressable::URI.parse(session["user_return_to"]) - uri ? uri.query_values["uid"] : nil + uri = Addressable::URI.parse(session['user_return_to']) + if uri && uri.query_values + uri.query_values["username"] + else + nil + end end end diff --git a/app/views/sessions/new.haml b/app/views/sessions/new.haml index 5da4d36db..b2b04f9b1 100644 --- a/app/views/sessions/new.haml +++ b/app/views/sessions/new.haml @@ -26,7 +26,7 @@ %p = f.label :username , t('username') - = f.text_field :username, :tabindex => 1 , :value => prefilled_username + = f.text_field :username, :tabindex => 1, :value => prefilled_username %br %p diff --git a/features/oauth.feature b/features/oauth.feature index 22a3f4274..a50af1ac0 100644 --- a/features/oauth.feature +++ b/features/oauth.feature @@ -32,8 +32,7 @@ Feature: oauth And I fill in "Diaspora ID" with "bob@localhost:9887" And I press "Connect to Diaspora" Then I should be on the new user session page - And I debug - And I should see "bob" within "#user_username" + And the "Username" field within "#user_new" should contain "bob" Scenario: Not authorize Chubbies When I try to authorize Chubbies From 7f0677ab1640cdc3e78a8f43d7da59acba51cf97 Mon Sep 17 00:00:00 2001 From: Raphael Sofaer Date: Tue, 16 Aug 2011 18:23:09 -0700 Subject: [PATCH 10/11] connect wip --- app/controllers/authorizations_controller.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/controllers/authorizations_controller.rb b/app/controllers/authorizations_controller.rb index 30e0a174b..679dc7d47 100644 --- a/app/controllers/authorizations_controller.rb +++ b/app/controllers/authorizations_controller.rb @@ -12,13 +12,14 @@ class AuthorizationsController < ApplicationController if params[:uid].present? && params[:uid] != current_user.username sign_out current_user redirect_to url_with_prefilled_session_form - end - @requested_scopes = params["scope"].split(',') - @client = oauth2_authorization_request.client + else + @requested_scopes = params["scope"].split(',') + @client = oauth2_authorization_request.client - if authorization = current_user.authorizations.where(:client_id => @client.id).first - ac = authorization.authorization_codes.create(:redirect_uri => params[:redirect_uri]) - redirect_to "#{params[:redirect_uri]}&code=#{ac.code}" + if authorization = current_user.authorizations.where(:client_id => @client.id).first + ac = authorization.authorization_codes.create(:redirect_uri => params[:redirect_uri]) + redirect_to "#{params[:redirect_uri]}&code=#{ac.code}" + end end end From bcae8a1952eaca9b7a6bd859ae94de09cfe76fe6 Mon Sep 17 00:00:00 2001 From: Maxwell Salzberg Date: Tue, 23 Aug 2011 17:16:15 -0700 Subject: [PATCH 11/11] chubbies needs its own way of assigning a current user --- spec/chubbies/app.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/chubbies/app.rb b/spec/chubbies/app.rb index f924f98d5..d6f3b3250 100644 --- a/spec/chubbies/app.rb +++ b/spec/chubbies/app.rb @@ -64,6 +64,10 @@ module Chubbies @user = User.first end + def current_user= user + @user = user + end + def redirect_path '/callback' end