mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-08 16:54:31 +00:00
Fix user creation failure handling in OAuth paths (#29207)
This commit is contained in:
parent
844aa59bdf
commit
d4d0565b0f
|
@ -17,6 +17,9 @@ class Auth::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
||||||
session["devise.#{provider}_data"] = request.env['omniauth.auth']
|
session["devise.#{provider}_data"] = request.env['omniauth.auth']
|
||||||
redirect_to new_user_registration_url
|
redirect_to new_user_registration_url
|
||||||
end
|
end
|
||||||
|
rescue ActiveRecord::RecordInvalid
|
||||||
|
flash[:alert] = I18n.t('devise.failure.omniauth_user_creation_failure') if is_navigational_format?
|
||||||
|
redirect_to new_user_session_url
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ en:
|
||||||
last_attempt: You have one more attempt before your account is locked.
|
last_attempt: You have one more attempt before your account is locked.
|
||||||
locked: Your account is locked.
|
locked: Your account is locked.
|
||||||
not_found_in_database: Invalid %{authentication_keys} or password.
|
not_found_in_database: Invalid %{authentication_keys} or password.
|
||||||
|
omniauth_user_creation_failure: Error creating an account for this identity.
|
||||||
pending: Your account is still under review.
|
pending: Your account is still under review.
|
||||||
timeout: Your session expired. Please login again to continue.
|
timeout: Your session expired. Please login again to continue.
|
||||||
unauthenticated: You need to login or sign up before continuing.
|
unauthenticated: You need to login or sign up before continuing.
|
||||||
|
|
|
@ -60,11 +60,13 @@ describe 'OmniAuth callbacks' do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when ALLOW_UNSAFE_AUTH_PROVIDER_REATTACH is not set to true' do
|
context 'when ALLOW_UNSAFE_AUTH_PROVIDER_REATTACH is not set to true' do
|
||||||
it 'does not match the existing user or create an identity' do
|
it 'does not match the existing user or create an identity, and redirects to login page' do
|
||||||
expect { subject }
|
expect { subject }
|
||||||
.to not_change(User, :count)
|
.to not_change(User, :count)
|
||||||
.and not_change(Identity, :count)
|
.and not_change(Identity, :count)
|
||||||
.and not_change(LoginActivity, :count)
|
.and not_change(LoginActivity, :count)
|
||||||
|
|
||||||
|
expect(response).to redirect_to(new_user_session_url)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue