Feature parity with admins and users (also a minor backend change)
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user