Skip to content

Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.

fix: improve auth error messages and unify username validation length

AndyYang0e8f1b1c81f9
diff --git a/internal/handler/auth.go b/internal/handler/auth.go
index aabe3528e..58fb8d384 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 333c0055f..1c28cfbf8 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"`
}