Implement better permission check

This commit is contained in:
rxdn 2022-05-30 20:33:42 +01:00
parent c3775d03b8
commit d9e4df9e8e

View File

@ -48,12 +48,23 @@ func CloseTicket(ctx *gin.Context) {
// Verify the ticket exists
if ticket.UserId == 0 {
ctx.AbortWithStatusJSON(404, gin.H{
"success": true,
"success": false,
"error": "Ticket does not exist",
})
return
}
hasPermission, err := utils.HasPermissionToViewTicket(guildId, userId, ticket)
if err != nil {
ctx.JSON(500, utils.ErrorJson(err))
return
}
if !hasPermission {
ctx.JSON(403, utils.ErrorStr("You do not have permission to close this ticket"))
return
}
data := closerelay.TicketClose{
GuildId: guildId,
TicketId: ticket.Id,