From c1f9c88624adb434be3253c80f349fd1c227e15c Mon Sep 17 00:00:00 2001 From: mingmingmon Date: Sun, 25 Aug 2024 14:54:50 +0900 Subject: [PATCH] =?UTF-8?q?refactor(FileService,=20AuthUtil):=20=EB=B6=88?= =?UTF-8?q?=ED=95=84=EC=9A=94=ED=95=9C=20=EC=A3=BC=EC=84=9D=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0,=20=EA=B3=B5=EB=B0=B1=20=EC=A0=9C=EA=B1=B0=20#502?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../clab/api/global/auth/util/AuthUtil.java | 2 +- .../common/file/application/FileService.java | 36 ------------------- 2 files changed, 1 insertion(+), 37 deletions(-) diff --git a/src/main/java/page/clab/api/global/auth/util/AuthUtil.java b/src/main/java/page/clab/api/global/auth/util/AuthUtil.java index 362689e5b..3c59dc090 100644 --- a/src/main/java/page/clab/api/global/auth/util/AuthUtil.java +++ b/src/main/java/page/clab/api/global/auth/util/AuthUtil.java @@ -23,7 +23,7 @@ public static String getAuthenticationInfoMemberId() { return getAuthenticationInfo().getUsername(); } - public static Boolean isUserUnAuthenticated (Authentication authentication) { + public static Boolean isUserUnAuthenticated(Authentication authentication) { return (authentication == null || authentication.getAuthorities() == null || authentication.getAuthorities().isEmpty()); } } diff --git a/src/main/java/page/clab/api/global/common/file/application/FileService.java b/src/main/java/page/clab/api/global/common/file/application/FileService.java index e2f5c9651..2f165e264 100644 --- a/src/main/java/page/clab/api/global/common/file/application/FileService.java +++ b/src/main/java/page/clab/api/global/common/file/application/FileService.java @@ -223,42 +223,6 @@ private boolean isAssignmentAccessible(String url, Authentication authentication activityGroupAdminService.isMemberGroupLeaderRole(activityGroupId, authentication.getName()); } -/* public boolean isUserAccessibleByCategory(String category, String url, Authentication authentication) { - - if (category.equals("activity-photos")) { - return true; - } - - if (authentication == null || authentication.getAuthorities() == null || authentication.getAuthorities().isEmpty()) - return false; - - UploadedFile uploadedFile = uploadedFileService.getUploadedFileByUrl(url); - String uploaderId = uploadedFile.getUploader(); - GrantedAuthority authority = authentication.getAuthorities().iterator().next(); - String roleName = authority.getAuthority().replace("ROLE_", ""); - Role role = Role.valueOf(roleName); - - if (!roleCategoryMap.getOrDefault(role, Set.of()).contains(category)) { - return false; - } - - switch (category) { - case "boards", "profiles", "membership-fee", "activity-photos": - return true; - - case "members": - return (authentication.getName().equals(uploaderId)); - - case "assignments": - String[] parts = url.split("/"); - Long activityGroupId = Long.parseLong(parts[4]); - return (authentication.getName().equals(uploaderId) || - activityGroupAdminService.isMemberGroupLeaderRole(activityGroupId, authentication.getName())); - default: - return false; - } - }*/ - private String getCategoryByUrl(String url) { String basePath = fileURL + "/"; String category = "";