refactor: consolidate debug flag and update gitignore

- Rename debugMode to isDebug for consistency across codebase
- Move debug flag check in ValidateTimeStamp to match other validations
- Add database.db to gitignore and remove unused config file
- Update README.md to clarify user registration rules
This commit is contained in:
2026-02-28 15:48:01 +08:00
parent ff62e3e755
commit b46f6dbfc2
8 changed files with 32 additions and 27 deletions
+9 -4
View File
@@ -35,6 +35,7 @@ func RegisterHandler(w http.ResponseWriter, r *http.Request) {
if !ValidateTimeStamp(r.Header) {
SendErrorResponse(w, http.StatusBadRequest, "Invalid or missing X-Timestamp in header")
postLog.Warning(fmt.Sprintf("[RegisterHandler] Invalid or missing X-Timestamp in header: %s", r.Header.Get("X-Timestamp")))
return
}
@@ -219,8 +220,10 @@ func ValidateRequestWithBody(w http.ResponseWriter, r *http.Request, body []byte
return 0, "", fmt.Errorf("Token is required in header: %s", token)
}
if !ValidateTimeStamp(r.Header) {
return 0, "", fmt.Errorf("Invalid or missing X-Timestamp in header")
if !isDebug {
if !ValidateTimeStamp(r.Header) {
return 0, "", fmt.Errorf("Invalid or missing X-Timestamp in header")
}
}
userID, err := extractUserIDFromToken(token)
@@ -247,8 +250,10 @@ func ValidateRequestWithHeader(w http.ResponseWriter, r *http.Request, requiredF
return 0, "", fmt.Errorf("Token is required in header: %s", token)
}
if !ValidateTimeStamp(r.Header) {
return 0, "", fmt.Errorf("Invalid or missing X-Timestamp in header")
if !isDebug {
if !ValidateTimeStamp(r.Header) {
return 0, "", fmt.Errorf("Invalid or missing X-Timestamp in header")
}
}
userID, err := extractUserIDFromToken(token)