fix(backend): dbErr 503 degradation for connection-class DB errors

This commit is contained in:
2026-09-06 19:53:19 +08:00
parent 04095b5438
commit a11bf28155
8 changed files with 61 additions and 18 deletions
+1 -3
View File
@@ -2,7 +2,6 @@ package api
import (
"errors"
"log"
"net/http"
"time"
@@ -28,8 +27,7 @@ func (a *api) login(c *gin.Context) {
u, qerr := a.st.GetUserByName(c, req.Username)
if qerr != nil {
if !errors.Is(qerr, pgx.ErrNoRows) {
log.Printf("db: %v", qerr)
err(c, http.StatusInternalServerError, "internal", "db error")
dbErr(c, qerr)
return
}
// 用户不存在也走一次 bcrypt,防用户名枚举时序差