2022-12-22 04:45:15 +00:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
2023-02-26 21:22:18 +00:00
|
|
|
_ "fmt"
|
2023-01-31 04:38:30 +00:00
|
|
|
"hacklab.nilfm.cc/quartzgun/auth"
|
2023-02-26 21:22:18 +00:00
|
|
|
_ "strings"
|
2022-12-22 04:45:15 +00:00
|
|
|
)
|
|
|
|
|
2023-02-26 21:22:18 +00:00
|
|
|
func ProcessCmd(args []string, userStore auth.UserStore) bool {
|
2022-12-22 04:45:15 +00:00
|
|
|
if len(args) == 1 {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
switch args[1] {
|
|
|
|
case "adduser":
|
|
|
|
if len(args) < 4 {
|
|
|
|
return help()
|
|
|
|
}
|
|
|
|
userStore.AddUser(args[2], args[3])
|
|
|
|
case "rmuser":
|
|
|
|
if len(args) < 3 {
|
|
|
|
return help()
|
|
|
|
}
|
|
|
|
userStore.DeleteUser(args[2])
|
|
|
|
case "passwd":
|
|
|
|
if len(args) < 5 {
|
|
|
|
return help()
|
|
|
|
}
|
|
|
|
userStore.ChangePassword(args[2], args[3], args[4])
|
|
|
|
default:
|
|
|
|
help()
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
func help() bool {
|
|
|
|
return true
|
|
|
|
}
|