fix empty desktop lists
This commit is contained in:
@@ -50,7 +50,7 @@ public class AppointmentController {
|
|||||||
.orElse(null);
|
.orElse(null);
|
||||||
|
|
||||||
Long effectiveCustomerId = customerId;
|
Long effectiveCustomerId = customerId;
|
||||||
if (role != null && (role.equals("CUSTOMER") || role.equals("ADMIN"))) {
|
if ("CUSTOMER".equals(role)) {
|
||||||
User user = AuthenticationHelper.getAuthenticatedUser(userRepository);
|
User user = AuthenticationHelper.getAuthenticatedUser(userRepository);
|
||||||
effectiveCustomerId = user.getId();
|
effectiveCustomerId = user.getId();
|
||||||
}
|
}
|
||||||
@@ -88,7 +88,7 @@ public class AppointmentController {
|
|||||||
.map(authority -> authority.getAuthority().replace("ROLE_", ""))
|
.map(authority -> authority.getAuthority().replace("ROLE_", ""))
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
|
|
||||||
if (role != null && (role.equals("CUSTOMER") || role.equals("ADMIN"))) {
|
if ("CUSTOMER".equals(role)) {
|
||||||
User user = AuthenticationHelper.getAuthenticatedUser(userRepository);
|
User user = AuthenticationHelper.getAuthenticatedUser(userRepository);
|
||||||
if (!request.getCustomerId().equals(user.getId())) {
|
if (!request.getCustomerId().equals(user.getId())) {
|
||||||
throw new org.springframework.security.access.AccessDeniedException("You can only create appointments for yourself");
|
throw new org.springframework.security.access.AccessDeniedException("You can only create appointments for yourself");
|
||||||
|
|||||||
@@ -247,7 +247,13 @@ public class PetService {
|
|||||||
if (principal instanceof AppPrincipal appPrincipal) {
|
if (principal instanceof AppPrincipal appPrincipal) {
|
||||||
return new CurrentViewer(appPrincipal.getUserId(), appPrincipal.getRole());
|
return new CurrentViewer(appPrincipal.getUserId(), appPrincipal.getRole());
|
||||||
}
|
}
|
||||||
return null;
|
String username = authentication.getName();
|
||||||
|
if (username == null || username.isBlank() || "anonymousUser".equalsIgnoreCase(username)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return userRepository.findByUsername(username)
|
||||||
|
.map(user -> new CurrentViewer(user.getId(), user.getRole()))
|
||||||
|
.orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Pet findPet(Long id) {
|
private Pet findPet(Long id) {
|
||||||
|
|||||||
Reference in New Issue
Block a user