refactor: replace raw SQL with repository interfaces in entranceserver and API server

Extract all direct database calls from entranceserver (2 calls) and
API server (17 calls) into typed repository interfaces with PostgreSQL
implementations, matching the pattern established in signserver and
channelserver.

Entranceserver: EntranceServerRepo, EntranceSessionRepo
API server: APIUserRepo, APICharacterRepo, APISessionRepo

Also fix the 3 remaining fmt.Sprintf calls inside logger invocations
in handlers_commands.go and handlers_stage.go, replacing them with
structured zap fields.

Unskip 5 TestNewAuthData* tests that previously required a real
database — they now run with mock repos.
This commit is contained in:
Houmgaor
2026-02-22 17:04:58 +01:00
parent f640cfee27
commit 82b967b715
18 changed files with 601 additions and 115 deletions

View File

@@ -162,12 +162,7 @@ func (s *APIServer) Login(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(400)
return
}
var (
userID uint32
userRights uint32
password string
)
err := s.db.QueryRow("SELECT id, password, rights FROM users WHERE username = $1", reqData.Username).Scan(&userID, &password, &userRights)
userID, password, userRights, err := s.userRepo.GetCredentials(ctx, reqData.Username)
if err == sql.ErrNoRows {
w.WriteHeader(400)
_, _ = w.Write([]byte("username-error"))