A platform for community discussion. Free, open, simple.
FIX: do not enforce 2fa when an account is created with OAuth (#28625)
Krzysztof Kotlarekb90b56f95300
diff --git a/app/services/user_activator.rb b/app/services/user_activator.rbindex 6d45907fbfe..1e611235b1e 100644--- a/app/services/user_activator.rb+++ b/app/services/user_activator.rb@@ -67,7 +67,7 @@ class LoginActivator < UserActivatorinclude CurrentUserdef activate- log_on_user(user)+ log_on_user(user, { authenticated_with_oauth: @session["authenticated_with_oauth"] })user.enqueue_welcome_message("welcome_user")success_messageenddiff --git a/app/services/user_authenticator.rb b/app/services/user_authenticator.rbindex 73dbe04e2a4..c0ce7ef3d94 100644--- a/app/services/user_authenticator.rb+++ b/app/services/user_authenticator.rb@@ -36,7 +36,10 @@ class UserAuthenticatorauthenticator.after_create_account(@user, @auth_result)confirm_emailend- @session[:authentication] = @auth_result = nil if @session&.dig(:authentication)+ if @session&.dig(:authentication)+ @session[:authentication] = @auth_result = nil+ @session[:authenticated_with_oauth] = true+ endenddef email_valid?diff --git a/spec/services/user_authenticator_spec.rb b/spec/services/user_authenticator_spec.rbindex 5e476e38c64..c96db48880f 100644--- a/spec/services/user_authenticator_spec.rb+++ b/spec/services/user_authenticator_spec.rb@@ -81,6 +81,15 @@ RSpec.describe UserAuthenticator doexpect(session[:authentication]).to eq(nil)end+ it "sets the authenticated_with_oauth flag in the session" do+ user = Fabricate(:user, email: "[email protected]")+ session = { authentication: github_auth(true) }++ UserAuthenticator.new(user, session).finish++ expect(session[:authenticated_with_oauth]).to be true+ end+it "raises an error for non-boolean values" douser = Fabricate(:user, email: "[email protected]")session = { authentication: github_auth("string") }