all repos — honk @ db582287736dac7593852ab064267de1d2d37b55

my fork of honk

deluser command
Ted Unangst tedu@tedunangst.com
Tue, 10 Dec 2019 14:03:44 -0500
commit

db582287736dac7593852ab064267de1d2d37b55

parent

8c9d0a87faca2df7932405aab5bd3a15983f42d4

4 files changed, 35 insertions(+), 0 deletions(-)

jump to
M docs/changelog.txtdocs/changelog.txt

@@ -2,6 +2,8 @@ changelog

-- next ++ deluser command. + + @media print styles. + Disable overscroll (pull down) refresh.
M docs/honk.8docs/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 honk.gohonk.go

@@ -252,6 +252,12 @@ log.Fatal("argument must be on or off")

} case "adduser": adduser() + case "deluser": + if len(args) < 2 { + fmt.Printf("usage: honk deluser username\n") + return + } + deluser(args[1]) case "chpass": chpass() case "cleanup":
M util.goutil.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")