diff --git a/app/controllers/oauth/authorizations_controller.rb b/app/controllers/oauth/authorizations_controller.rb index 833aeabf31a..e6daf25a9e9 100644 --- a/app/controllers/oauth/authorizations_controller.rb +++ b/app/controllers/oauth/authorizations_controller.rb @@ -41,7 +41,7 @@ class OAuth::AuthorizationsController < Doorkeeper::AuthorizationsController if params['prompt'] == 'create' && !current_user session[:registration_app_id] = Doorkeeper::OAuth::Client.find(params[:client_id]).id - return redirect_to(new_user_registration_path) + return redirect_to(new_user_registration_path(params.permit(:invite_code))) end super diff --git a/spec/system/oauth_spec.rb b/spec/system/oauth_spec.rb index d6532b58e0a..b40be794844 100644 --- a/spec/system/oauth_spec.rb +++ b/spec/system/oauth_spec.rb @@ -165,10 +165,11 @@ RSpec.describe 'Using OAuth from an external app' do context 'when creating a new user' do let(:params) do - { client_id: client_app.uid, response_type: 'code', redirect_uri: client_app.redirect_uri, scope: 'read', prompt: 'create' } + { client_id: client_app.uid, response_type: 'code', redirect_uri: client_app.redirect_uri, scope: 'read', prompt: 'create', invite_code: invite.code } end let!(:rule) { Fabricate :rule, text: 'You must be seven meters tall' } + let(:invite) { Fabricate :invite, autofollow: true } it 'allows creating a new user' do subject @@ -183,6 +184,7 @@ RSpec.describe 'Using OAuth from an external app' do # It presents the user with a sign-up page expect(page) .to have_text(I18n.t('auth.register')) + .and have_text(I18n.t('invites.invited_by')) # Avoid the registration spam check travel_to 10.seconds.from_now