Separate admin protected endpoints from non-admin endpoints

This commit is contained in:
2026-03-10 12:32:47 +00:00
parent 0b256863d6
commit bad44a6ddd
4 changed files with 34 additions and 35 deletions

View File

@@ -67,11 +67,6 @@ func (store *Store) CreatePost(ctx *gin.Context) {
}
userID := uint(userIDF)
if !(*claims)["admin"].(bool) {
ctx.JSON(http.StatusForbidden, gin.H{"error": "you are not admin :("})
return
}
// Create post
post := models.Post{Title: input.Title, Content: input.Content, AuthorID: userID}
tx := store.DB.Create(&post)