snoopdave commented on code in PR #223:
URL: https://github.com/apache/roller/pull/223#discussion_r4394334070


##########
app/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/PreviewServlet.java:
##########
@@ -293,4 +301,21 @@ public void doGet(HttpServletRequest request, 
HttpServletResponse response)
         log.debug("Exiting");
     }
     
+
+    /**
+     * Previews show unpublished content, so only an enabled user with a role
+     * in the weblog (or a global admin) may see them.
+     */
+    static boolean canPreview(Weblog weblog, User user) {
+        if (weblog == null || user == null || 
!Boolean.TRUE.equals(user.getEnabled())) {
+            return false;
+        }
+        try {
+            return 
WebloggerFactory.getWeblogger().getUserManager().checkPermission(

Review Comment:
   **Important:** The javadoc promises "(or a global admin)" passes, and 
`JPAUserManagerImpl.checkPermission` does grant that via 
`GlobalPermission.implies`, but no test pins that branch. 
`PreviewServletPermissionTest` covers owner / member-with-draft / non-member / 
disabled / null — worth adding the global-admin-without-membership case (grant 
no weblog permission to a global-admin user, assert `canPreview` is true) so 
the behavior the fix relies on for site admins previewing other weblogs' themes 
stays covered through refactors.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to