deluser command
This commit is contained in:
parent
f0acc4e357
commit
de04ec6e83
|
@ -2,6 +2,8 @@ changelog
|
||||||
|
|
||||||
-- next
|
-- next
|
||||||
|
|
||||||
|
+ deluser command.
|
||||||
|
|
||||||
+ @media print styles.
|
+ @media print styles.
|
||||||
|
|
||||||
+ Disable overscroll (pull down) refresh.
|
+ Disable overscroll (pull down) refresh.
|
||||||
|
|
|
@ -111,6 +111,10 @@ This is discouraged.
|
||||||
Passwords may be reset with the
|
Passwords may be reset with the
|
||||||
.Ic chpass Ar username
|
.Ic chpass Ar username
|
||||||
command.
|
command.
|
||||||
|
.Pp
|
||||||
|
Users may be deleted with the
|
||||||
|
.Ic deluser Ar username
|
||||||
|
command.
|
||||||
.Ss Maintenance
|
.Ss Maintenance
|
||||||
The database may grow large over time.
|
The database may grow large over time.
|
||||||
The
|
The
|
||||||
|
|
6
honk.go
6
honk.go
|
@ -252,6 +252,12 @@ func main() {
|
||||||
}
|
}
|
||||||
case "adduser":
|
case "adduser":
|
||||||
adduser()
|
adduser()
|
||||||
|
case "deluser":
|
||||||
|
if len(args) < 2 {
|
||||||
|
fmt.Printf("usage: honk deluser username\n")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
deluser(args[1])
|
||||||
case "chpass":
|
case "chpass":
|
||||||
chpass()
|
chpass()
|
||||||
case "cleanup":
|
case "cleanup":
|
||||||
|
|
23
util.go
23
util.go
|
@ -210,6 +210,29 @@ func adduser() {
|
||||||
os.Exit(0)
|
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() {
|
func chpass() {
|
||||||
if len(os.Args) < 3 {
|
if len(os.Args) < 3 {
|
||||||
fmt.Printf("need a username\n")
|
fmt.Printf("need a username\n")
|
||||||
|
|
Loading…
Reference in New Issue