Add invitation support to OAuth-signup code through invite_code parameter

This commit is contained in:
Claire
2026-10-05 16:27:24 +02:00
parent c236df4eac
commit 9ad8897fc6
2 changed files with 4 additions and 2 deletions

View File

@@ -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

View File

@@ -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