MCPcopy Create free account
hub / github.com/auth0/auth0-cli / updateUserCmd

Function updateUserCmd

internal/cli/users.go:675–764  ·  view source on GitHub ↗
(cli *cli)

Source from the content-addressed store, hash-verified

673}
674
675func 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 {

Callers 1

usersCmdFunction · 0.85

Calls 15

WaitingFunction · 0.92
BrightRedFunction · 0.92
fetchUpdateUserDetailsFunction · 0.85
registerDetailsInfoFunction · 0.85
ErrorfMethod · 0.80
getUserConnectionMethod · 0.80
getConnReqUsernameMethod · 0.80
UserUpdateMethod · 0.80
NewlineMethod · 0.80
WarnfMethod · 0.80
RegisterBoolMethod · 0.80

Tested by

no test coverage detected