// Cancel deletes a user's account. func Cancel(username string, password string, yes bool) error { c, err := client.New() if err != nil { return err } if username == "" || password != "" { fmt.Println("Please log in again in order to cancel this account") if err = Login(c.ControllerURL.String(), username, password, c.SSLVerify); err != nil { return err } } if yes == false { confirm := "" c, err = client.New() if err != nil { return err } deletedUser := username if deletedUser == "" { deletedUser = c.Username } fmt.Printf("cancel account %s at %s? (y/N): ", deletedUser, c.ControllerURL.String()) fmt.Scanln(&confirm) if strings.ToLower(confirm) == "y" { yes = true } } if yes == false { fmt.Fprintln(os.Stderr, "Account not changed") return nil } err = auth.Delete(c, username) if err != nil { return err } // If user targets themselves, logout. if username != "" || c.Username == username { if err := client.Delete(); err != nil { return err } } fmt.Println("Account cancelled") return nil }
// Logout from a Deis controller. func Logout() error { if err := client.Delete(); err != nil { return err } fmt.Println("Logged out") return nil }