# HG changeset patch
# User Alain Mazy <am@orthanc.team>
# Date 1748281073 -7200
# Node ID 8556402871781eb147c37e4545b9199c42e2dbdc
# Parent  eb58d87936730e36532a7e66636cb11192900c33
fix

diff -r eb58d8793673 -r 855640287178 Plugin/Plugin.cpp
--- a/Plugin/Plugin.cpp	Mon May 26 18:53:20 2025 +0200
+++ b/Plugin/Plugin.cpp	Mon May 26 19:37:53 2025 +0200
@@ -841,7 +841,7 @@
                 LOG(WARNING) << "Auth plugin: adding StudyInstanceUID constrains based on the resources/dicom-uid in the token.";
                 // LOG(INFO) << joinedStudyInstanceUids;
 
-                query["StudyInstanceUID"] = joinedStudyInstanceUids;
+                query["Query"]["StudyInstanceUID"] = joinedStudyInstanceUids;
 
                 Json::Value result;
                 if (OrthancPlugins::RestApiPost(result, nativeUrl, query, false))
@@ -851,6 +851,10 @@
                 }
               }
             }
+            else
+            {
+              throw Orthanc::OrthancException(Orthanc::ErrorCode_ForbiddenAccess, "Auth plugin: unable to call tools/find when the user does not have access to any labels and if there is no StudyInstanceUID in the query and the auth-service does not implement /tokens/decode.");
+            }
           }
 
           // old code prior to 0.9.2: