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

Ensure we set `just_registered` only for users that were just created

Oliver Günther6d6d6aeb09a4
diff --git a/app/controllers/concerns/accounts/omniauth_login.rb b/app/controllers/concerns/accounts/omniauth_login.rb
index 48dea07fbb4..a6f8e80e949 100644
--- a/app/controllers/concerns/accounts/omniauth_login.rb
+++ b/app/controllers/concerns/accounts/omniauth_login.rb
@@ -90,7 +90,7 @@ module Accounts::OmniauthLogin
if call.success?
flash[:notice] = call.message.presence
- login_user_if_active(call.result, just_registered: true)
+ login_user_if_active(call.result, just_registered: call.result.just_created?)
elsif call.includes_error?(:base, :failed_to_activate)
redirect_omniauth_register_modal(call.result, auth_hash)
else
diff --git a/app/models/application_record.rb b/app/models/application_record.rb
index bdd23013245..64c6a62d6a3 100644
--- a/app/models/application_record.rb
+++ b/app/models/application_record.rb
@@ -7,6 +7,12 @@ class ApplicationRecord < ::ActiveRecord::Base
self.class.find(self.class.primary_key)
end
+ ##
+ # Determine whether this resource was just created ?
+ def just_created?
+ saved_change_to_attribute?(:id)
+ end
+
##
# Get the newest recently changed resource for the given record classes
#