Restricted getting account details

This commit is contained in:
Andrey Terentev 2024-03-26 00:58:57 +07:00 committed by Andrey Terentev
parent 743c3a9d21
commit d0a1e253b8

View File

@ -2,6 +2,7 @@ package ru.dragonestia.picker.controller;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -22,6 +23,7 @@ public class AccountsController {
return account.toResponseObject(); return account.toResponseObject();
} }
@PreAuthorize("hasRole('ADMIN')")
@GetMapping("/{accountId}") @GetMapping("/{accountId}")
ResponseEntity<ResponseAccount> findAccount(@PathVariable String accountId) { ResponseEntity<ResponseAccount> findAccount(@PathVariable String accountId) {
try { try {