Exemplo n.º 1
0
func userDelAction(c *cli.Context) {
	super, err := context.CheckSuperPerm(context.Config.User)
	if err != nil {
		fmt.Println(err)
		return
	}
	if !super {
		fmt.Println("You have no permission to this operation")
		return
	}

	username := c.String("u")

	fmt.Printf("Type %s to continue: ", "yes")
	var cmd string
	fmt.Scanf("%s\n", &cmd)
	if cmd != "yes" {
		return
	}
	_, version, err := context.GetUser(username)
	if err != nil {
		fmt.Println(err)
		return
	}
	err = context.DelUser(username, version)
	if err != nil {
		fmt.Println(err)
		return
	} else {
		fmt.Printf("Delete %s success\n", username)
	}
}
Exemplo n.º 2
0
func userGetAction(c *cli.Context) {
	super, err := context.CheckSuperPerm(context.Config.User)
	if err != nil {
		fmt.Println(err)
		return
	}
	if !super {
		fmt.Println("You have no permission to this operation")
		return
	}
	username := c.String("u")

	if username == "" {
		fmt.Println("-u,username must be assigned")
		return
	}

	token, _, err := context.GetUser(username)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Printf("User:%s\nToken:%s\n", username, token)
}