chore: build
ci-web / test (push) Canceled after 0s
ci-api / test (push) Canceled after 24s

This commit is contained in:
Xor290
2026-08-22 21:58:39 +02:00
parent f407bc3dd0
commit 0f28d4757e
9 changed files with 164 additions and 11 deletions
+21
View File
@@ -137,3 +137,24 @@ func (h *Handler) AddCode(c *gin.Context) {
}
c.JSON(http.StatusOK, gin.H{"success": "vous passez en abonnement premium"})
}
// GetPremiumUser : GET /premium — liste des clients premium (nom, date de
// saisie du code, date de fin d'abonnement) pour l'admin.
func (h *Handler) GetPremiumUser(c *gin.Context) {
p := auth.PrincipalFrom(c)
if p == nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": "non authentifié"})
return
}
if p.Role != "admin" {
c.JSON(http.StatusForbidden, gin.H{"error": "vous n'avez pas les droits"})
return
}
items, err := h.store.GetUserPremium()
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": "erreur serveur"})
return
}
c.JSON(http.StatusOK, gin.H{"items": items})
}