diff --git a/app/controllers/authorizations_controller.rb b/app/controllers/authorizations_controller.rb index 7158e29dd2226b25178cc24372dfabe3935624b9..e15a60b3d557849b46108189dceb69890e2b0bdc 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 92dba9a7308b9dea46c819310830689b2a99f116..beae15c23d052e28abd04ba4862c428711ddffd6 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 1a50afb691721c004aa15af95e2273e36b480241..c1f0705fd79ae72c74fcc4ea106966d286c59ae5 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 0e75311d9ea3de700c95978df7ca21bed8e32880..f924f98d5d26422656440774fee045a1ae977d80 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 b97443537753fa2a851e1a3714d78739169ec1ed..eb5963edc3fe38ed4236df73ec244f1836b79b3a 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" }