spring-boot-blog-application
spring-boot-blog-application copied to clipboard
Can't write more than one blogpost & only delete when the user is admin
Hello,
I have got this problem where I can create only ONE blog entry and then an error is thrown on the "posts/new/" page the moment I want to create a new one. And one can only delete entries when the user is admin. Also to be mentioned: The Blog entry in the database is stored even when it was deleted on the FrontEnd.
Hmm that first issue should be already addressed if you pull the latest @thiemt-armando (my apologies for not seeing this until now)
Yes, in the PostController
notice how the delete
mapping is guarded with a PreAuthorize
with a role. I wanted to have the restriction where ONLY accounts with the ROLE_ADMIN
role could delete a post. Feel free to change that on your own setup!
@GetMapping("/posts/{id}/delete")
@PreAuthorize("hasRole('ROLE_ADMIN')")