chore: drop demo-user permission (#2045)

This commit is contained in:
James Ward
2026-07-18 17:25:48 -04:00
committed by GitHub
parent b68e022fc0
commit f2b64c1b6e
7 changed files with 2 additions and 18 deletions
@@ -59,7 +59,6 @@ public enum ApiError {
TASK_NOT_FOUND(HttpStatus.NOT_FOUND, "Scheduled task not found: %s"), TASK_NOT_FOUND(HttpStatus.NOT_FOUND, "Scheduled task not found: %s"),
TASK_ALREADY_RUNNING(HttpStatus.CONFLICT, "Task is already running: %s"), TASK_ALREADY_RUNNING(HttpStatus.CONFLICT, "Task is already running: %s"),
ICON_ALREADY_EXISTS(HttpStatus.CONFLICT, "SVG icon with name '%s' already exists"), ICON_ALREADY_EXISTS(HttpStatus.CONFLICT, "SVG icon with name '%s' already exists"),
DEMO_USER_PASSWORD_CHANGE_NOT_ALLOWED(HttpStatus.FORBIDDEN, "Demo user password change not allowed."),
PERMISSION_DENIED(HttpStatus.FORBIDDEN, "Permission denied: %s"), PERMISSION_DENIED(HttpStatus.FORBIDDEN, "Permission denied: %s"),
LIBRARY_PATH_NOT_ACCESSIBLE(HttpStatus.SERVICE_UNAVAILABLE, "Library scan aborted: path not accessible or empty: %s"), LIBRARY_PATH_NOT_ACCESSIBLE(HttpStatus.SERVICE_UNAVAILABLE, "Library scan aborted: path not accessible or empty: %s"),
FORMAT_NOT_ALLOWED(HttpStatus.BAD_REQUEST, "File format '%s' is not allowed in library '%s'"), FORMAT_NOT_ALLOWED(HttpStatus.BAD_REQUEST, "File format '%s' is not allowed in library '%s'"),
@@ -91,10 +91,6 @@ public class UserPermissionsEntity {
@Builder.Default @Builder.Default
private boolean permissionManageFonts = false; private boolean permissionManageFonts = false;
@Column(name = "permission_demo_user", nullable = false)
@Builder.Default
private boolean permissionDemoUser = false;
@Column(name = "permission_bulk_auto_fetch_metadata", nullable = false) @Column(name = "permission_bulk_auto_fetch_metadata", nullable = false)
@Builder.Default @Builder.Default
private boolean permissionBulkAutoFetchMetadata = false; private boolean permissionBulkAutoFetchMetadata = false;
@@ -22,8 +22,7 @@ public enum PermissionType {
ACCESS_TASK_MANAGER("permissionAccessTaskManager"), ACCESS_TASK_MANAGER("permissionAccessTaskManager"),
MANAGE_GLOBAL_PREFERENCES("permissionManageGlobalPreferences"), MANAGE_GLOBAL_PREFERENCES("permissionManageGlobalPreferences"),
MANAGE_ICONS("permissionManageIcons"), MANAGE_ICONS("permissionManageIcons"),
MANAGE_FONTS("permissionManageFonts"), MANAGE_FONTS("permissionManageFonts");
DEMO_USER("permissionDemoUser");
private final String entityField; private final String entityField;
@@ -167,10 +167,6 @@ public class UserService {
BookLoreUserEntity bookLoreUserEntity = userRepository.findByIdWithPermissions(bookLoreUser.getId()) BookLoreUserEntity bookLoreUserEntity = userRepository.findByIdWithPermissions(bookLoreUser.getId())
.orElseThrow(() -> ApiError.USER_NOT_FOUND.createException(bookLoreUser.getId())); .orElseThrow(() -> ApiError.USER_NOT_FOUND.createException(bookLoreUser.getId()));
if (bookLoreUserEntity.getPermissions().isPermissionDemoUser()) {
throw ApiError.DEMO_USER_PASSWORD_CHANGE_NOT_ALLOWED.createException();
}
if (!passwordEncoder.matches(changePasswordRequest.getCurrentPassword(), bookLoreUserEntity.getPasswordHash())) { if (!passwordEncoder.matches(changePasswordRequest.getCurrentPassword(), bookLoreUserEntity.getPasswordHash())) {
throw ApiError.PASSWORD_INCORRECT.createException(); throw ApiError.PASSWORD_INCORRECT.createException();
} }
@@ -28,7 +28,6 @@ public class UserPermissionUtils {
case MANAGE_ICONS -> perms.isPermissionManageIcons(); case MANAGE_ICONS -> perms.isPermissionManageIcons();
case MANAGE_FONTS -> perms.isPermissionManageFonts(); case MANAGE_FONTS -> perms.isPermissionManageFonts();
case MANAGE_GLOBAL_PREFERENCES -> perms.isPermissionManageGlobalPreferences(); case MANAGE_GLOBAL_PREFERENCES -> perms.isPermissionManageGlobalPreferences();
case DEMO_USER -> perms.isPermissionDemoUser();
}; };
} }
@@ -52,7 +51,6 @@ public class UserPermissionUtils {
case MANAGE_ICONS -> perms.isCanManageIcons(); case MANAGE_ICONS -> perms.isCanManageIcons();
case MANAGE_FONTS -> perms.isCanManageFonts(); case MANAGE_FONTS -> perms.isCanManageFonts();
case MANAGE_GLOBAL_PREFERENCES -> perms.isCanManageGlobalPreferences(); case MANAGE_GLOBAL_PREFERENCES -> perms.isCanManageGlobalPreferences();
case DEMO_USER -> perms.isDemoUser();
}; };
} }
} }
@@ -0,0 +1 @@
ALTER TABLE user_permissions DROP COLUMN IF EXISTS permission_demo_user;
@@ -60,7 +60,6 @@ class UserPermissionUtilsTest {
.permissionManageGlobalPreferences(false) .permissionManageGlobalPreferences(false)
.permissionManageIcons(false) .permissionManageIcons(false)
.permissionManageFonts(false) .permissionManageFonts(false)
.permissionDemoUser(false)
.permissionAdmin(false) .permissionAdmin(false)
.build(); .build();
@@ -89,7 +88,6 @@ class UserPermissionUtilsTest {
.permissionManageGlobalPreferences(true) .permissionManageGlobalPreferences(true)
.permissionManageIcons(true) .permissionManageIcons(true)
.permissionManageFonts(true) .permissionManageFonts(true)
.permissionDemoUser(true)
.permissionAdmin(true) .permissionAdmin(true)
.build(); .build();
@@ -117,7 +115,6 @@ class UserPermissionUtilsTest {
.permissionManageGlobalPreferences(false) .permissionManageGlobalPreferences(false)
.permissionManageIcons(false) .permissionManageIcons(false)
.permissionManageFonts(false) .permissionManageFonts(false)
.permissionDemoUser(false)
.permissionAdmin(false); .permissionAdmin(false);
switch (permissionType) { switch (permissionType) {
@@ -138,7 +135,6 @@ class UserPermissionUtilsTest {
case MANAGE_GLOBAL_PREFERENCES -> builder.permissionManageGlobalPreferences(value); case MANAGE_GLOBAL_PREFERENCES -> builder.permissionManageGlobalPreferences(value);
case MANAGE_ICONS -> builder.permissionManageIcons(value); case MANAGE_ICONS -> builder.permissionManageIcons(value);
case MANAGE_FONTS -> builder.permissionManageFonts(value); case MANAGE_FONTS -> builder.permissionManageFonts(value);
case DEMO_USER -> builder.permissionDemoUser(value);
case ADMIN -> builder.permissionAdmin(value); case ADMIN -> builder.permissionAdmin(value);
default -> throw new IllegalArgumentException("Test helper missing mapping for PermissionType: " + permissionType); default -> throw new IllegalArgumentException("Test helper missing mapping for PermissionType: " + permissionType);
} }
@@ -186,7 +182,6 @@ class UserPermissionUtilsTest {
case MANAGE_GLOBAL_PREFERENCES -> perms.setCanManageGlobalPreferences(value); case MANAGE_GLOBAL_PREFERENCES -> perms.setCanManageGlobalPreferences(value);
case MANAGE_ICONS -> perms.setCanManageIcons(value); case MANAGE_ICONS -> perms.setCanManageIcons(value);
case MANAGE_FONTS -> perms.setCanManageFonts(value); case MANAGE_FONTS -> perms.setCanManageFonts(value);
case DEMO_USER -> perms.setDemoUser(value);
case ADMIN -> perms.setAdmin(value); case ADMIN -> perms.setAdmin(value);
default -> throw new IllegalArgumentException("Test helper missing mapping for PermissionType: " + permissionType); default -> throw new IllegalArgumentException("Test helper missing mapping for PermissionType: " + permissionType);
} }