chore: drop demo-user permission (#2045)
This commit is contained in:
@@ -59,7 +59,6 @@ public enum ApiError {
|
||||
TASK_NOT_FOUND(HttpStatus.NOT_FOUND, "Scheduled task not found: %s"),
|
||||
TASK_ALREADY_RUNNING(HttpStatus.CONFLICT, "Task is already running: %s"),
|
||||
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"),
|
||||
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'"),
|
||||
|
||||
@@ -91,10 +91,6 @@ public class UserPermissionsEntity {
|
||||
@Builder.Default
|
||||
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)
|
||||
@Builder.Default
|
||||
private boolean permissionBulkAutoFetchMetadata = false;
|
||||
|
||||
@@ -22,8 +22,7 @@ public enum PermissionType {
|
||||
ACCESS_TASK_MANAGER("permissionAccessTaskManager"),
|
||||
MANAGE_GLOBAL_PREFERENCES("permissionManageGlobalPreferences"),
|
||||
MANAGE_ICONS("permissionManageIcons"),
|
||||
MANAGE_FONTS("permissionManageFonts"),
|
||||
DEMO_USER("permissionDemoUser");
|
||||
MANAGE_FONTS("permissionManageFonts");
|
||||
|
||||
private final String entityField;
|
||||
|
||||
|
||||
@@ -167,10 +167,6 @@ public class UserService {
|
||||
BookLoreUserEntity bookLoreUserEntity = userRepository.findByIdWithPermissions(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())) {
|
||||
throw ApiError.PASSWORD_INCORRECT.createException();
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ public class UserPermissionUtils {
|
||||
case MANAGE_ICONS -> perms.isPermissionManageIcons();
|
||||
case MANAGE_FONTS -> perms.isPermissionManageFonts();
|
||||
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_FONTS -> perms.isCanManageFonts();
|
||||
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)
|
||||
.permissionManageIcons(false)
|
||||
.permissionManageFonts(false)
|
||||
.permissionDemoUser(false)
|
||||
.permissionAdmin(false)
|
||||
.build();
|
||||
|
||||
@@ -89,7 +88,6 @@ class UserPermissionUtilsTest {
|
||||
.permissionManageGlobalPreferences(true)
|
||||
.permissionManageIcons(true)
|
||||
.permissionManageFonts(true)
|
||||
.permissionDemoUser(true)
|
||||
.permissionAdmin(true)
|
||||
.build();
|
||||
|
||||
@@ -117,7 +115,6 @@ class UserPermissionUtilsTest {
|
||||
.permissionManageGlobalPreferences(false)
|
||||
.permissionManageIcons(false)
|
||||
.permissionManageFonts(false)
|
||||
.permissionDemoUser(false)
|
||||
.permissionAdmin(false);
|
||||
|
||||
switch (permissionType) {
|
||||
@@ -138,7 +135,6 @@ class UserPermissionUtilsTest {
|
||||
case MANAGE_GLOBAL_PREFERENCES -> builder.permissionManageGlobalPreferences(value);
|
||||
case MANAGE_ICONS -> builder.permissionManageIcons(value);
|
||||
case MANAGE_FONTS -> builder.permissionManageFonts(value);
|
||||
case DEMO_USER -> builder.permissionDemoUser(value);
|
||||
case ADMIN -> builder.permissionAdmin(value);
|
||||
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_ICONS -> perms.setCanManageIcons(value);
|
||||
case MANAGE_FONTS -> perms.setCanManageFonts(value);
|
||||
case DEMO_USER -> perms.setDemoUser(value);
|
||||
case ADMIN -> perms.setAdmin(value);
|
||||
default -> throw new IllegalArgumentException("Test helper missing mapping for PermissionType: " + permissionType);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user