deluser command
Ted Unangst tedu@tedunangst.com
Tue, 10 Dec 2019 14:03:44 -0500
4 files changed,
35 insertions(+),
0 deletions(-)
M
docs/changelog.txt
→
docs/changelog.txt
@@ -2,6 +2,8 @@ changelog
-- next ++ deluser command. + + @media print styles. + Disable overscroll (pull down) refresh.
M
docs/honk.8
→
docs/honk.8
@@ -111,6 +111,10 @@ .Pp
Passwords may be reset with the .Ic chpass Ar username command. +.Pp +Users may be deleted with the +.Ic deluser Ar username +command. .Ss Maintenance The database may grow large over time. The
M
util.go
→
util.go
@@ -210,6 +210,29 @@
os.Exit(0) } +func deluser(username string) { + user, _ := butwhatabout(username) + if user == nil { + log.Printf("no userfound") + return + } + userid := user.ID + db := opendatabase() + + where := " where honkid in (select honkid from honks where userid = ?)" + doordie(db, "delete from donks"+where, userid) + doordie(db, "delete from onts"+where, userid) + doordie(db, "delete from honkmeta"+where, userid) + + doordie(db, "delete from honks where userid = ?", userid) + doordie(db, "delete from honkers where userid = ?", userid) + doordie(db, "delete from zonkers where userid = ?", userid) + doordie(db, "delete from doovers where userid = ?", userid) + doordie(db, "delete from hfcs where userid = ?", userid) + doordie(db, "delete from auth where userid = ?", userid) + doordie(db, "delete from users where userid = ?", userid) +} + func chpass() { if len(os.Args) < 3 { fmt.Printf("need a username\n")