Circular dependancy issue when working on hardening

This commit is contained in:
2025-03-25 16:43:16 +00:00
parent 1a531af4f8
commit b58a8bdb82
8 changed files with 96 additions and 23 deletions

View File

@@ -35,3 +35,17 @@ func GetUserByUsername(username string) *User {
}
return &user
}
func GetUserByID(id int) *User {
row := db.QueryRow("SELECT id, username, password_hash FROM users WHERE id = ?", id)
var user User
err := row.Scan(&user.Id, &user.Username, &user.PasswordHash)
if err != nil {
if err != sql.ErrNoRows {
log.Println("DB error:", err)
}
return nil
}
return &user
}