db_sqlite: fix realname not fetched in ListUsers

This fixes per-user realname not being used on bouncer startup.
This commit is contained in:
Simon Ser 2021-10-05 11:10:48 +02:00
parent 5bedcd24e2
commit 1b8d8d08c9

View File

@ -216,7 +216,7 @@ func (db *SqliteDB) ListUsers() ([]User, error) {
db.lock.RLock() db.lock.RLock()
defer db.lock.RUnlock() defer db.lock.RUnlock()
rows, err := db.db.Query("SELECT id, username, password, admin FROM User") rows, err := db.db.Query("SELECT id, username, password, admin, realname FROM User")
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -225,11 +225,12 @@ func (db *SqliteDB) ListUsers() ([]User, error) {
var users []User var users []User
for rows.Next() { for rows.Next() {
var user User var user User
var password sql.NullString var password, realname sql.NullString
if err := rows.Scan(&user.ID, &user.Username, &password, &user.Admin); err != nil { if err := rows.Scan(&user.ID, &user.Username, &password, &user.Admin, &realname); err != nil {
return nil, err return nil, err
} }
user.Password = password.String user.Password = password.String
user.Realname = realname.String
users = append(users, user) users = append(users, user)
} }
if err := rows.Err(); err != nil { if err := rows.Err(); err != nil {