File tree Expand file tree Collapse file tree
src/main/java/inu/codin/codinticketingapi/security/util Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33import inu .codin .codinticketingapi .security .exception .SecurityErrorCode ;
44import inu .codin .codinticketingapi .security .exception .SecurityException ;
55import inu .codin .codinticketingapi .security .jwt .TokenUserDetails ;
6- import io .jsonwebtoken .JwtException ;
76import org .springframework .security .core .Authentication ;
87import 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 }
You canβt perform that action at this time.
0 commit comments