Skip to content

Commit

Permalink
fix: switch to InsufficientAuthenticationException (401, Unauthorized…
Browse files Browse the repository at this point in the history
…) if user in not superuser
  • Loading branch information
Atifsid committed May 1, 2024
1 parent 60e41c8 commit e6c249d
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.authentication.InsufficientAuthenticationException;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

Expand Down Expand Up @@ -70,7 +70,7 @@ public GenericResponse<Void> updateEndorsementStatus(String id, String status) {
UserModel user =
(UserModel) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
if (!user.getRole().equals(UserRole.SUPERUSER)) {
throw new AccessDeniedException("Unauthorized access");
throw new InsufficientAuthenticationException("Unauthorized access");
}
if (!(Objects.equals(status, EndorsementStatus.APPROVED.name())
|| Objects.equals(status, EndorsementStatus.REJECTED.name()))) {
Expand Down

0 comments on commit e6c249d

Please sign in to comment.