terminado carrito

This commit is contained in:
2025-10-31 11:36:03 +01:00
parent 90c191d8f8
commit 40dc719e89
13 changed files with 234 additions and 59 deletions

View File

@ -14,6 +14,7 @@ import java.util.function.BiFunction;
import org.springframework.context.MessageSource;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;
import com.fasterxml.jackson.core.JsonProcessingException;
@ -44,6 +45,12 @@ public class Utils {
this.messageSource = messageSource;
}
public static boolean isCurrentUserAdmin() {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
return auth.getAuthorities().stream()
.anyMatch(a -> a.getAuthority().equals("ROLE_ADMIN") || a.getAuthority().equals("ROLE_SUPERADMIN"));
}
public static Long currentUserId(Principal principal) {
if (principal == null) {