From 1bec2349cbbf6072c3b71a2c8b7749a3bf2d6a65 Mon Sep 17 00:00:00 2001 From: vilmibm Date: Thu, 16 Mar 2023 06:15:12 +0000 Subject: [PATCH] set created and admin when inserting user --- cmd/welcome/main.go | 2 ++ towndb/towndb.go | 9 ++------- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/cmd/welcome/main.go b/cmd/welcome/main.go index 2316c11..c0017ea 100644 --- a/cmd/welcome/main.go +++ b/cmd/welcome/main.go @@ -7,6 +7,7 @@ import ( "fmt" "os" "os/exec" + "time" "git.tilde.town/tildetown/town/invites" "git.tilde.town/tildetown/town/stats" @@ -182,6 +183,7 @@ func createUser(data newUserData) (err error) { tu := towndb.TownUser{ Username: data.Username, + Created: time.Now(), Emails: []string{ data.Email, }, diff --git a/towndb/towndb.go b/towndb/towndb.go index 234127c..13ac7e6 100644 --- a/towndb/towndb.go +++ b/towndb/towndb.go @@ -83,14 +83,9 @@ func (u *TownUser) Insert(db *sql.DB) (err error) { } }() - // TODO this does not set the admin flag intentionally as rn this code is - // just meant to be called by the welcome binary; other stuff for now is just - // expected to be done via sql - - u.Created = time.Now() if stmt, err = tx.Prepare(` - INSERT INTO users (created, username, state) - VALUES (?, ?, ?)`); err != nil { + INSERT INTO users (created, username, state, admin) + VALUES (?, ?, ?, ?)`); err != nil { return err }