From 0e8f1b1c81f9f0cddc62dc94d74863dee9e21e59 Mon Sep 17 00:00:00 2001 From: AndyYang Date: Sun, 15 Mar 2026 11:09:20 +0800 Subject: [PATCH] fix: improve auth error messages and unify username validation length --- internal/handler/auth.go | 2 +- internal/types/user.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/handler/auth.go b/internal/handler/auth.go index aabe3528..58fb8d38 100644 --- a/internal/handler/auth.go +++ b/internal/handler/auth.go @@ -87,7 +87,7 @@ func (h *AuthHandler) Register(c *gin.Context) { user, err := h.userService.Register(ctx, &req) if err != nil { logger.Errorf(ctx, "Failed to register user: %v", err) - appErr := errors.NewBadRequestError("Registration failed").WithDetails(err.Error()) + appErr := errors.NewBadRequestError(err.Error()) c.Error(appErr) return } diff --git a/internal/types/user.go b/internal/types/user.go index 333c0055..1c28cfbf 100644 --- a/internal/types/user.go +++ b/internal/types/user.go @@ -66,7 +66,7 @@ type LoginRequest struct { // RegisterRequest represents a registration request type RegisterRequest struct { - Username string `json:"username" binding:"required,min=3,max=50"` + Username string `json:"username" binding:"required,min=2,max=50"` Email string `json:"email" binding:"required,email"` Password string `json:"password" binding:"required,min=6"` }