Skip to content

Commit ec29a7b

Browse files
committed
Merge branch 'master' into daveProtocol
# Conflicts: # gradle.properties
2 parents 5514c75 + bd1f896 commit ec29a7b

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
projectVersion=4.1.47
1+
projectVersion=4.1.48
22
org.gradle.configuration-cache=false

src/main/java/net/dirtydeeds/discordsoundboard/util/UserRoleConfig.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public class UserRoleConfig {
4848
/**
4949
* Get roles for a specific user
5050
* Database roles take precedence over configuration file roles
51+
* Default "user" role is only assigned to authenticated users (non-null/non-empty userId)
5152
*/
5253
public List<String> getUserRoles(String userId) {
5354
List<String> returnRoles = new ArrayList<>();
@@ -77,6 +78,12 @@ public List<String> getUserRoles(String userId) {
7778
// 3. Fallback to YAML roles map
7879
returnRoles.addAll(roles.getOrDefault(userId, new ArrayList<>()));
7980

81+
// If the user is not authenticated then return the configured roles. This is intended to just skip the defaulting
82+
// of the "user" role.
83+
if (userId == null || userId.isEmpty()) {
84+
return returnRoles;
85+
}
86+
8087
// 4. If no roles assigned, give default "user" role
8188
if (returnRoles.isEmpty()) {
8289
returnRoles.add("user");

0 commit comments

Comments
 (0)