Skip to content

Commit af5104f

Browse files
authored
🐜 fix: κΆŒν•œ 검증 λ‘œμ§μ—μ„œ 접두사 λˆ„λ½μœΌλ‘œ ROLE 비ꡐ가 μ•ˆλ˜λŠ” 문제 ν•΄κ²°
🐜 fix: κΆŒν•œ 검증 λ‘œμ§μ—μ„œ 접두사 λˆ„λ½μœΌλ‘œ ROLE 비ꡐ가 μ•ˆλ˜λŠ” 문제 ν•΄κ²°
2 parents 0ab98cf + 2c20668 commit af5104f

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

β€Žsrc/main/java/inu/codin/codinticketingapi/security/util/SecurityUtil.javaβ€Ž

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import inu.codin.codinticketingapi.security.exception.SecurityErrorCode;
44
import inu.codin.codinticketingapi.security.exception.SecurityException;
55
import inu.codin.codinticketingapi.security.jwt.TokenUserDetails;
6-
import io.jsonwebtoken.JwtException;
76
import org.springframework.security.core.Authentication;
87
import org.springframework.security.core.context.SecurityContextHolder;
98

@@ -90,7 +89,9 @@ public static boolean isAuthenticated() {
9089
public static boolean hasRole(String role) {
9190
try {
9291
String currentRole = getCurrentUserRole();
93-
return role.equals(currentRole);
92+
String withPrefix = role.startsWith("ROLE_") ? role : "ROLE_" + role;
93+
94+
return role.equals(currentRole) || withPrefix.equals(currentRole);
9495
} catch (SecurityException e) {
9596
return false;
9697
}

0 commit comments

Comments
Β (0)