fix bug in user service

This commit is contained in:
Dustin Pianalto
2021-01-23 14:46:25 -09:00
parent f85c475cfd
commit 121a21e1c6
2 changed files with 7 additions and 1 deletions
+6 -1
View File
@@ -20,7 +20,12 @@ func (s userService) User(id string) (geeksbot.User, error) {
func (s userService) CreateUser(u geeksbot.User) (geeksbot.User, error) {
queryString := "INSERT INTO users (id, steam_id, active, staff, admin) VALUES ($1, $2, $3, $4, $5)"
_, err := s.db.Exec(queryString, u.ID, u.SteamID, u.IsActive, u.IsStaff, u.IsAdmin)
var err error
if u.SteamID.Valid {
_, err = s.db.Exec(queryString, u.ID, u.SteamID.String, u.IsActive, u.IsStaff, u.IsAdmin)
} else {
_, err = s.db.Exec(queryString, u.ID, nil, u.IsActive, u.IsStaff, u.IsAdmin)
}
return u, err
}