Feature parity with admins and users (also a minor backend change)

This commit is contained in:
augmentedpotato
2026-04-07 23:23:05 -06:00
parent ffef9243dd
commit 83477904be
3 changed files with 8 additions and 18 deletions

View File

@@ -50,7 +50,7 @@ public class AppointmentController {
.orElse(null);
Long effectiveCustomerId = customerId;
if (role != null && role.equals("CUSTOMER")) {
if (role != null && (role.equals("CUSTOMER") || role.equals("ADMIN"))) {
User user = AuthenticationHelper.getAuthenticatedUser(userRepository);
effectiveCustomerId = user.getId();
}
@@ -88,7 +88,7 @@ public class AppointmentController {
.map(authority -> authority.getAuthority().replace("ROLE_", ""))
.orElse(null);
if (role != null && role.equals("CUSTOMER")) {
if (role != null && (role.equals("CUSTOMER") || role.equals("ADMIN"))) {
User user = AuthenticationHelper.getAuthenticatedUser(userRepository);
if (!request.getCustomerId().equals(user.getId())) {
throw new org.springframework.security.access.AccessDeniedException("You can only create appointments for yourself");