bugfix permission delete when only permissionId specified
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -146,14 +146,28 @@ func DeletePermissionHandler(c *gin.Context) {
|
||||
p.Description = html.EscapeString(strings.TrimSpace(p.Description))
|
||||
|
||||
// Check if permission definition already exists
|
||||
testPermission, _ := models.PermissionGetByDesc(p.Description)
|
||||
if len(p.Description) > 0 {
|
||||
log.Printf("DeletePermissionHandler confirming permission with description '%s' exists\n", p.Description)
|
||||
testPermission, _ := models.PermissionGetByDesc(p.Description)
|
||||
|
||||
if (models.Permission{} == testPermission) {
|
||||
errString := fmt.Sprintf("attempt to delete non-existing permission with description '%s'", p.Description)
|
||||
log.Printf("DeletePermissionHandler %s\n", errString)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": errString})
|
||||
return
|
||||
}
|
||||
} else {
|
||||
log.Printf("DeletePermissionHandler confirming permission with id '%d' exists\n", p.PermissionId)
|
||||
testPermission, _ := models.PermissionGetById(p.PermissionId)
|
||||
|
||||
if (models.Permission{} == testPermission) {
|
||||
errString := fmt.Sprintf("attempt to delete non-existing permission with id '%d'", p.PermissionId)
|
||||
log.Printf("DeletePermissionHandler %s\n", errString)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": errString})
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
err := p.PermissionDelete()
|
||||
|
||||
// Create audit record
|
||||
@@ -172,7 +186,7 @@ func DeletePermissionHandler(c *gin.Context) {
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"message": "permission deletion success"})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func UpdatePermissionHandler(c *gin.Context) {
|
||||
|
Reference in New Issue
Block a user