Skip to content

Commit bd1f896

Browse files
committed
Making the user role only get defaulted for logged in users. This way "default" permissions are separate for authenticated vs non-authenticated users.
1 parent c3bfe96 commit bd1f896

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.37
1+
projectVersion=4.1.38
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)