chore: build
This commit is contained in:
@@ -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})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user