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

Update authentication calls

Marcello Rocha01eaad7034e6
diff --git a/modules/storages/app/services/storages/file_links/copy_file_links_service.rb b/modules/storages/app/services/storages/file_links/copy_file_links_service.rb
index de940826044..1c37edad527 100644
--- a/modules/storages/app/services/storages/file_links/copy_file_links_service.rb
+++ b/modules/storages/app/services/storages/file_links/copy_file_links_service.rb
@@ -64,10 +64,17 @@ module Storages
# rubocop:disable Metrics/AbcSize
def create_managed_file_links(source_file_links)
- location_map = build_location_map(
- source_files_info(source_file_links).result,
- target_files_map.result
- )
+ source_info = source_files_info(source_file_links).on_failure do |failed|
+ log_errors(failed)
+ return failed
+ end
+
+ target_map = target_files_map.on_failure do |failed|
+ log_errors(failed)
+ return failed
+ end
+
+ location_map = build_location_map(source_info.result, target_map.result)
source_file_links.find_each do |source_link|
next unless location_map.has_key?(source_link.origin_id)
@@ -83,7 +90,6 @@ module Storages
.call(attributes).on_failure { |failed| log_errors(failed) }
end
end
-
# rubocop:enable Metrics/AbcSize
# rubocop:disable Metrics/AbcSize
@@ -102,16 +108,12 @@ module Storages
output[id] = target_location_map[target]&.id || id
end
end
-
# rubocop:enable Metrics/AbcSize
def auth_strategy
- Peripherals::StorageInteraction::AuthenticationStrategies::OAuthUserToken
- .strategy
- .with_user(@user)
+ Peripherals::Registry.resolve("#{@source.storage.short_provider_type}.authentication.userless").call
end
- # Known issue, this can lead to 403s.
def source_files_info(source_file_links)
Peripherals::Registry
.resolve("#{@source.storage.short_provider_type}.queries.files_info")
@@ -121,7 +123,7 @@ module Storages
def target_files_map
Peripherals::Registry
.resolve("#{@source.storage.short_provider_type}.queries.file_path_to_id_map")
- .call(storage: @source.storage, folder: Peripherals::ParentFolder.new(@target.project_folder_location))
+ .call(storage: @source.storage, auth_strategy:, folder: Peripherals::ParentFolder.new(@target.project_folder_location))
end
def create_unmanaged_file_links(source_file_links)