Skip to content

Commit

Permalink
Fix no permission through global role given
Browse files Browse the repository at this point in the history
Dependency updates
  • Loading branch information
Alf-Melmac committed Nov 13, 2023
1 parent ae76241 commit 62dfa93
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
<!--https://github.com/atteo/classindex/tags -->
<classindex.version>3.13</classindex.version>
<!--https://github.com/DV8FromTheWorld/JDA/releases -->
<jda.version>5.0.0-beta.16</jda.version>
<jda.version>5.0.0-beta.17</jda.version>
<!--https://jsoup.org/news/ -->
<jsoup.version>1.16.2</jsoup.version>
<!--https://github.com/ical4j/ical4j/tags -->
<ical4j.version>4.0.0-beta9</ical4j.version>
<ical4j.version>4.0.0-rc1</ical4j.version>
<!--https://github.com/vojtechhabarta/typescript-generator/releases -->
<typescript-generator.version>3.2.1263</typescript-generator.version>
<!--https://github.com/springdoc/springdoc-openapi/releases -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ public static boolean isLoggedInUser(long userId) {
* @return true if allowed
*/
public static boolean hasPermissionInGuild(@NonNull Role role, long guildId) {
if (role == SYSTEM_ADMIN) { //global role
return true;
}
final Stream<? extends GrantedAuthority> authorities = SecurityContextHolder.getContext().getAuthentication().getAuthorities().stream();
final Set<String> authorizedRoles = role.getAuthorizedRoles().stream().map(authorizedRole -> ROLE_PREFIX + authorizedRole.getApplicationRole()).collect(Collectors.toUnmodifiableSet());
if (guildId == GUILD_PLACEHOLDER) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/webalf/slotbot/util/permissions/Role.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
@Getter
@AllArgsConstructor
public enum Role {
SYSTEM_ADMIN(ApplicationRole.SYS_ADMIN),
SYSTEM_ADMIN(ApplicationRole.SYS_ADMIN), //Asserted as a global role
ADMINISTRATOR(ApplicationRole.ADMIN),
EVENT_MANAGE(ApplicationRole.EVENT_MANAGE);

Expand Down

0 comments on commit 62dfa93

Please sign in to comment.