Change redirection for denied registration from web app to sign-in page with error message (#36384)

pull/36482/head
Claire 3 weeks ago committed by GitHub
parent c6de46d12d
commit fab0dd0bcf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -89,7 +89,7 @@ class Auth::RegistrationsController < Devise::RegistrationsController
end end
def check_enabled_registrations def check_enabled_registrations
redirect_to root_path unless allowed_registration?(request.remote_ip, @invite) redirect_to new_user_session_path, alert: I18n.t('devise.failure.closed_registrations', email: Setting.site_contact_email) unless allowed_registration?(request.remote_ip, @invite)
end end
def invite_code def invite_code

@ -7,6 +7,7 @@ en:
send_paranoid_instructions: If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes. Please check your spam folder if you didn't receive this email. send_paranoid_instructions: If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes. Please check your spam folder if you didn't receive this email.
failure: failure:
already_authenticated: You are already signed in. already_authenticated: You are already signed in.
closed_registrations: Your registration attempt has been blocked due to a network policy. If you believe this is an error, contact %{email}.
inactive: Your account is not activated yet. inactive: Your account is not activated yet.
invalid: Invalid %{authentication_keys} or password. invalid: Invalid %{authentication_keys} or password.
last_attempt: You have one more attempt before your account is locked. last_attempt: You have one more attempt before your account is locked.

@ -12,11 +12,11 @@ RSpec.describe Auth::RegistrationsController do
allow(Rails.configuration.x).to receive(:single_user_mode).and_return(true) allow(Rails.configuration.x).to receive(:single_user_mode).and_return(true)
end end
it 'redirects to root' do it 'redirects to sign-in' do
Fabricate(:account) Fabricate(:account)
get path get path
expect(response).to redirect_to '/' expect(response).to redirect_to '/auth/sign_in'
expect(Rails.configuration.x).to have_received(:single_user_mode) expect(Rails.configuration.x).to have_received(:single_user_mode)
end end
end end
@ -27,10 +27,10 @@ RSpec.describe Auth::RegistrationsController do
allow(Rails.configuration.x).to receive(:single_user_mode).and_return(false) allow(Rails.configuration.x).to receive(:single_user_mode).and_return(false)
end end
it 'redirects to root' do it 'redirects to sign-in' do
get path get path
expect(response).to redirect_to '/' expect(response).to redirect_to '/auth/sign_in'
expect(Rails.configuration.x).to have_received(:single_user_mode) expect(Rails.configuration.x).to have_received(:single_user_mode)
end end
end end

Loading…
Cancel
Save