chore: finish profile
ci-api / test (push) Failing after 11m37s
ci-web / test (push) Successful in 14m39s

This commit is contained in:
Nuxgrid
2026-07-29 14:50:31 +02:00
parent 5a0c1bfe3f
commit 6beabfb070
16 changed files with 137 additions and 527 deletions
@@ -23,6 +23,10 @@ type newPassword struct {
Password string `json:"password" binding:"required,min=8"`
}
type newTelegram struct {
Telegram string `json:"telegram" binding:"required,min=3,max=64"`
}
func (h *Handler) UpdateUsernameById(c *gin.Context) {
var u newUsername
@@ -73,3 +77,36 @@ func (h *Handler) UpdatePasswordById(c *gin.Context) {
c.JSON(http.StatusOK, user)
}
func (h *Handler) GetTelegramById(c *gin.Context) {
id, ok := c.MustGet("id").(string)
if !ok {
c.JSON(http.StatusUnauthorized, gin.H{"error": "id invalide"})
return
}
user, err := h.store.GetTelegram(id)
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": "requête invalide"})
return
}
c.JSON(http.StatusOK, gin.H{"telegram": user.Telegram})
}
func (h *Handler) SetTelegramById(c *gin.Context) {
var t newTelegram
if err := c.ShouldBindJSON(&t); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": "requête invalide"})
return
}
id, ok := c.MustGet("id").(string)
if !ok {
c.JSON(http.StatusUnauthorized, gin.H{"error": "id invalide"})
return
}
user, err := h.store.SetTelegram(id, t.Telegram)
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": "erreur serveur"})
return
}
c.JSON(http.StatusOK, gin.H{"telegram": user.Telegram})
}