set created and admin when inserting user

pull/2/head
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" "fmt"
"os" "os"
"os/exec" "os/exec"
"time"
"git.tilde.town/tildetown/town/invites" "git.tilde.town/tildetown/town/invites"
"git.tilde.town/tildetown/town/stats" "git.tilde.town/tildetown/town/stats"
@ -182,6 +183,7 @@ func createUser(data newUserData) (err error) {
tu := towndb.TownUser{ tu := towndb.TownUser{
Username: data.Username, Username: data.Username,
Created: time.Now(),
Emails: []string{ Emails: []string{
data.Email, 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(` if stmt, err = tx.Prepare(`
INSERT INTO users (created, username, state) INSERT INTO users (created, username, state, admin)
VALUES (?, ?, ?)`); err != nil { VALUES (?, ?, ?, ?)`); err != nil {
return err return err
} }