From 9ad8897fc61d976181a730bbfc72b92c1a8a6dca Mon Sep 17 00:00:00 2001 From: Claire Date: Mon, 5 Oct 2026 16:27:24 +0200 Subject: [PATCH] Add invitation support to OAuth-signup code through `invite_code` parameter --- app/controllers/oauth/authorizations_controller.rb | 2 +- spec/system/oauth_spec.rb | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) 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