flounder

A simple gemini site builder
Log | Files | Refs | README | LICENSE

commit 419c92fa3571df38efab35b01e3b8b23d5e4559e
parent 3384eb4f1e94daa548dadcd5d074d59edc0c7eb0
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Sat, 31 Oct 2020 12:40:49 -0700

add make admin command

Diffstat:
Madmin.go | 12++++++++++++
1 file changed, 12 insertions(+), 0 deletions(-)

diff --git a/admin.go b/admin.go @@ -31,11 +31,23 @@ func runAdminCommand() { // TODO add confirmation err := deleteUser(username) log.Fatal(err) + case "make-admin": + username := os.Args[3] + err := makeAdmin(username) + log.Fatal(err) } // reset password } +func makeAdmin(username string) error { + _, err := DB.Exec("UPDATE user SET admin = true WHERE username = $1", username) + if err != nil { + return err + } + return nil +} + func activateUser(username string) error { _, err := DB.Exec("UPDATE user SET active = true WHERE username = $1", username) if err != nil {