set created and admin when inserting user

trunk
vilmibm 2023-03-16 06:15:12 +00:00
parent e12d92735d
commit 1bec2349cb
2 changed files with 4 additions and 7 deletions

View File

@ -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,
},

View File

@ -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
}