fix: delete keys and seed only active ones

Ensure admin key deletion removes the DB record and returns a
"deleted" status. Update seeder idempotency to count only active keys
when deciding whether to skip or create new keys.
This commit is contained in:
zenfun
2026-01-10 01:18:04 +08:00
parent 5349c9c833
commit e7db9f319f
2 changed files with 31 additions and 9 deletions

View File

@@ -516,8 +516,8 @@ func (h *AdminHandler) ListKeysForMaster(c *gin.Context) {
}
// DeleteKeyForMaster godoc
// @Summary Delete (revoke) child key
// @Description Suspends a child key under the specified master
// @Summary Delete child key
// @Description Revokes and removes a child key under the specified master
// @Tags admin
// @Produce json
// @Security AdminAuth
@@ -561,5 +561,10 @@ func (h *AdminHandler) DeleteKeyForMaster(c *gin.Context) {
return
}
c.JSON(http.StatusOK, gin.H{"status": "revoked"})
if err := h.db.Delete(&k).Error; err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": "failed to delete token", "details": err.Error()})
return
}
c.JSON(http.StatusOK, gin.H{"status": "deleted"})
}