This commit is contained in:
@@ -155,7 +155,7 @@ func AddUser(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"message": "user registration success"})
|
||||
c.JSON(http.StatusOK, gin.H{"message": "user registration success", "data": u})
|
||||
}
|
||||
|
||||
func Login(c *gin.Context) {
|
||||
|
@@ -118,27 +118,47 @@ func DeleteGroupHandler(c *gin.Context) {
|
||||
g.GroupId = input.GroupId
|
||||
g.GroupName = input.GroupName
|
||||
|
||||
//remove leading/trailing spaces in groupname
|
||||
g.GroupName = html.EscapeString(strings.TrimSpace(g.GroupName))
|
||||
if g.GroupId > 0 { // Group Id was specified
|
||||
// Confirm group exists
|
||||
testGroup, _ := models.GroupGetById(g.GroupId)
|
||||
log.Printf("DeleteGroupHandler confirming group id '%d' exists\n", g.GroupId)
|
||||
|
||||
// Confirm group exists
|
||||
testGroup, _ := models.GroupGetByName(g.GroupName)
|
||||
log.Printf("DeleteGroupHandler confirming group '%s' exists\n", g.GroupName)
|
||||
if (models.Group{} == testGroup) {
|
||||
errString := fmt.Sprintf("attempt to delete non-existing group '%s'", g.GroupName)
|
||||
log.Printf("DeleteGroupHandler %s\n", errString)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": errString})
|
||||
return
|
||||
} else {
|
||||
err := g.GroupDelete()
|
||||
if (models.Group{} == testGroup) {
|
||||
errString := fmt.Sprintf("attempt to delete non-existing group id '%d'", g.GroupId)
|
||||
log.Printf("DeleteGroupHandler %s\n", errString)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": errString})
|
||||
return
|
||||
}
|
||||
g.GroupName = testGroup.GroupName
|
||||
} else if len(g.GroupName) > 0 { // Group name was specified
|
||||
//remove leading/trailing spaces in groupname
|
||||
g.GroupName = html.EscapeString(strings.TrimSpace(g.GroupName))
|
||||
|
||||
if err != nil {
|
||||
errString := fmt.Sprintf("error deleting group : '%s'", err)
|
||||
// Confirm group exists
|
||||
testGroup, _ := models.GroupGetByName(g.GroupName)
|
||||
log.Printf("DeleteGroupHandler confirming group '%s' exists\n", g.GroupName)
|
||||
|
||||
if (models.Group{} == testGroup) {
|
||||
errString := fmt.Sprintf("attempt to delete non-existing group '%s'", g.GroupName)
|
||||
log.Printf("DeleteGroupHandler %s\n", errString)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": errString})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"message": "group deletion success"})
|
||||
g.GroupId = testGroup.GroupId
|
||||
}
|
||||
|
||||
// TODO verify no permissions refer to this group still
|
||||
|
||||
err := g.GroupDelete()
|
||||
|
||||
if err != nil {
|
||||
errString := fmt.Sprintf("error deleting group : '%s'", err)
|
||||
log.Printf("DeleteGroupHandler %s\n", errString)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": errString})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"message": "group deletion success"})
|
||||
|
||||
}
|
||||
|
@@ -320,7 +320,7 @@ func UpdateSecret(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"message": "secret updated successfully"})
|
||||
c.JSON(http.StatusOK, gin.H{"message": "secret updated successfully", "data": models.SecretRestricted(s)})
|
||||
} else {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "multiple secrets matched search parameters, be more specific"})
|
||||
return
|
||||
|
Reference in New Issue
Block a user