refactor: Sanitize log inputs in user, auth, knowledge, and model handlers to enhance security

This commit is contained in:
wizardchen
2025-11-26 10:50:53 +08:00
parent 8e3c2d8547
commit 09642445de
5 changed files with 20 additions and 11 deletions
+4 -1
View File
@@ -51,6 +51,9 @@ func (h *AuthHandler) Register(c *gin.Context) {
c.Error(appErr)
return
}
req.Username = secutils.SanitizeForLog(req.Username)
req.Email = secutils.SanitizeForLog(req.Email)
req.Password = secutils.SanitizeForLog(req.Password)
// Validate required fields
if req.Username == "" || req.Email == "" || req.Password == "" {
@@ -77,7 +80,7 @@ func (h *AuthHandler) Register(c *gin.Context) {
User: user,
}
logger.Infof(ctx, "User registered successfully: %s", user.Email)
logger.Infof(ctx, "User registered successfully: %s", secutils.SanitizeForLog(user.Email))
c.JSON(http.StatusCreated, response)
}