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

explicitly set secret and uid for oauth application

ulferts2280feeece49
diff --git a/app/services/oauth/persist_application_service.rb b/app/services/oauth/persist_application_service.rb
index ec73b2310b2..a95f1554e7c 100644
--- a/app/services/oauth/persist_application_service.rb
+++ b/app/services/oauth/persist_application_service.rb
@@ -42,6 +42,7 @@ module OAuth
def call(attributes)
set_defaults
application.attributes = attributes
+ set_secret_and_id
result, errors = validate_and_save(application, current_user)
ServiceResult.new success: result, errors:, result: application
@@ -53,5 +54,13 @@ module OAuth
application.owner = current_user
application.owner_type = 'User'
end
+
+ def set_secret_and_id
+ application.extend(OpenProject::ChangedBySystem)
+ application.change_by_system do
+ application.renew_secret if application.secret.blank?
+ application.uid = Doorkeeper::OAuth::Helpers::UniqueToken.generate if application.uid.blank?
+ end
+ end
end
end