(cli *cli)
| 673 | } |
| 674 | |
| 675 | func updateUserCmd(cli *cli) *cobra.Command { |
| 676 | var ( |
| 677 | inputs = &userInput{} |
| 678 | blocked bool |
| 679 | id string |
| 680 | ) |
| 681 | |
| 682 | cmd := &cobra.Command{ |
| 683 | Use: "update", |
| 684 | Args: cobra.MaximumNArgs(1), |
| 685 | Short: "Update a user", |
| 686 | Long: "Update a user.\n\n" + |
| 687 | "To update interactively, use `auth0 users update` with no arguments.\n\n" + |
| 688 | "To update non-interactively, supply the user id and other information through the available flags.", |
| 689 | Example: ` auth0 users update |
| 690 | auth0 users update <user-id> |
| 691 | auth0 users update <user-id> --name "John Doe" |
| 692 | auth0 users update <user-id> --blocked=true" |
| 693 | auth0 users update <user-id> --blocked=false" |
| 694 | auth0 users update <user-id> -n "John Kennedy" -e johnk@example.com --json |
| 695 | auth0 users update <user-id> -n "John Kennedy" -e johnk@example.com --json-compact |
| 696 | auth0 users update <user-id> -n "John Kennedy" -p <newPassword> |
| 697 | auth0 users update <user-id> -b |
| 698 | auth0 users update <user-id> -p <newPassword> |
| 699 | auth0 users update <user-id> -e johnk@example.com |
| 700 | auth0 users update <user-id> --phone-number +916898989899 |
| 701 | auth0 users update <user-id> -m +916898989899 --json`, |
| 702 | |
| 703 | RunE: func(cmd *cobra.Command, args []string) error { |
| 704 | if len(args) == 0 { |
| 705 | if err := userID.Ask(cmd, &id); err != nil { |
| 706 | return err |
| 707 | } |
| 708 | } else { |
| 709 | id = args[0] |
| 710 | } |
| 711 | |
| 712 | var current *management.User |
| 713 | |
| 714 | if err := ansi.Waiting(func() error { |
| 715 | var err error |
| 716 | current, err = cli.api.User.Read(cmd.Context(), id) |
| 717 | return err |
| 718 | }); err != nil { |
| 719 | return fmt.Errorf("failed to read user with ID %q: %w", id, err) |
| 720 | } |
| 721 | // Using getUserConnection to get connection name from user Identities |
| 722 | // just using current.connection will return empty. |
| 723 | conn := stringSliceToCommaSeparatedString(cli.getUserConnection(current)) |
| 724 | current.Connection = auth0.String(conn) |
| 725 | |
| 726 | if err := fetchUserInputByConnection(cmd, inputs, current); err != nil { |
| 727 | return err |
| 728 | } |
| 729 | |
| 730 | user := fetchUpdateUserDetails(inputs, current) |
| 731 | |
| 732 | if blocked { |
no test coverage detected