예제 #1
0
파일: userdel.go 프로젝트: ksarch-saas/cc
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)
	}
}
예제 #2
0
파일: userget.go 프로젝트: ksarch-saas/cc
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)
}