Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Avoid updating the just created user to retain id information

Oliver Günther2e2f52013041
diff --git a/app/services/authentication/omniauth_service.rb b/app/services/authentication/omniauth_service.rb
index 2255ba6a120..6cb58e159fc 100644
--- a/app/services/authentication/omniauth_service.rb
+++ b/app/services/authentication/omniauth_service.rb
@@ -77,7 +77,6 @@ module Authentication
# After login flow
def tap_service_result(call)
if call.success? && user.active?
- user.log_successful_login
OpenProject::OmniAuth::Authorization.after_login! user, auth_hash, self
end
diff --git a/app/services/users/login_service.rb b/app/services/users/login_service.rb
index 6ed68f15b51..63f2a295976 100644
--- a/app/services/users/login_service.rb
+++ b/app/services/users/login_service.rb
@@ -52,6 +52,8 @@ module Users
controller.session.merge!(retained_values) if retained_values
+ user.log_successful_login
+
ServiceResult.new(result: user)
end
diff --git a/spec/features/auth/omniauth_spec.rb b/spec/features/auth/omniauth_spec.rb
index 0934ef3e139..68f8922a4e2 100644
--- a/spec/features/auth/omniauth_spec.rb
+++ b/spec/features/auth/omniauth_spec.rb
@@ -184,11 +184,11 @@ describe 'Omniauth authentication', type: :feature do
click_link_or_button 'Create'
end
- expect(current_url).to eql home_url(first_time_user: true)
+ expect(page).to have_current_path home_path(first_time_user: true)
end
context 'with password login disabled',
- with_config: { disabled_password_login: 'true' } do
+ with_config: { disable_password_login: 'true' } do
it_behaves_like 'omniauth user registration'
end
diff --git a/spec/services/authentication/omniauth_service_spec.rb b/spec/services/authentication/omniauth_service_spec.rb
index 4fe33b58951..dc6d11df073 100644
--- a/spec/services/authentication/omniauth_service_spec.rb
+++ b/spec/services/authentication/omniauth_service_spec.rb
@@ -100,8 +100,6 @@ describe Authentication::OmniauthService do
# should update the user attributes
expect(user).to receive(:update).with(user_attributes)
- # Logs user login and calls callback
- expect(user).to receive(:log_successful_login)
expect(OpenProject::OmniAuth::Authorization)
.to(receive(:after_login!))
.with(user, auth_hash, instance)
@@ -154,8 +152,6 @@ describe Authentication::OmniauthService do
# should update the user attributes
expect(user).to receive(:update).with(user_attributes)
- # Logs user login and calls callback
- expect(user).to receive(:log_successful_login)
expect(OpenProject::OmniAuth::Authorization)
.to(receive(:after_login!))
.with(user, auth_hash, instance)
diff --git a/spec/services/users/login_service_spec.rb b/spec/services/users/login_service_spec.rb
index 74734f7de4b..0e52ae9b315 100644
--- a/spec/services/users/login_service_spec.rb
+++ b/spec/services/users/login_service_spec.rb
@@ -65,6 +65,9 @@ describe ::Users::LoginService, type: :model do
session.clear
flash.clear
end
+
+ allow(input_user)
+ .to receive(:log_successful_login)
end
context 'if provider retains session values' do