~emersion/sinwon

03bad951f6713fb5f70184550d8cb4546f22bc73 — Simon Ser 7 months ago 278a2a3
Fix admin ignored in DB.StoreUser
1 files changed, 4 insertions(+), 3 deletions(-)

M db.go
M db.go => db.go +4 -3
@@ 80,11 80,12 @@ func (db *DB) FetchUserByUsername(ctx context.Context, username string) (*User, 

func (db *DB) StoreUser(ctx context.Context, user *User) error {
	return db.db.QueryRowContext(ctx, `
		INSERT INTO User(id, username, password_hash)
		VALUES (:id, :username, :password_hash)
		INSERT INTO User(id, username, password_hash, admin)
		VALUES (:id, :username, :password_hash, :admin)
		ON CONFLICT(id) DO UPDATE SET
			username = :username,
			password_hash = :password_hash
			password_hash = :password_hash,
			admin = :admin
		RETURNING id
	`, entityArgs(user)...).Scan(&user.ID)
}