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

WIP - Added error message

Frank Bergmanncfe668b9a78b
diff --git a/modules/storages/app/services/storages/file_link_sync_service.rb b/modules/storages/app/services/storages/file_link_sync_service.rb
index 4a35e947b17..98625abb94f 100644
--- a/modules/storages/app/services/storages/file_link_sync_service.rb
+++ b/modules/storages/app/services/storages/file_link_sync_service.rb
@@ -53,10 +53,20 @@ class Storages::FileLinkSyncService
oauth_client = OAuthClient.find_by(integration_id: storage_id)
connection_manager = ::OAuthClients::ConnectionManager.new(user: @user, oauth_client:)
service_result = connection_manager.get_access_token # No scope for Nextcloud...
- oauth_client_token = service_result.result
- # Return the error codes from ConnectionManager.get_access_token to calling method
- return service_result unless service_result.success
+ # Return the errors from ConnectionManager.get_access_token to calling method
+ unless service_result.success do
+ # We should never get here, because the storages endpoint enforces OAuth auhorization
+ service_result.errors.add(
+ :base,
+ "User not authorized to access storage. \
+ Did you authorize OpenProject to connect to your storage with OAuth2?"
+ )
+
+ return service_result
+ end
+
+ oauth_client_token = service_result.result
# Get info about files. Result is either an Exception or Net::HTTPOK with body
storage_origin_file_ids = storage_file_links.map(&:origin_id)