(cli *cli)
| 563 | } |
| 564 | |
| 565 | func showUserCmd(cli *cli) *cobra.Command { |
| 566 | var inputs struct { |
| 567 | ID string |
| 568 | } |
| 569 | |
| 570 | cmd := &cobra.Command{ |
| 571 | Use: "show", |
| 572 | Args: cobra.MaximumNArgs(1), |
| 573 | Short: "Show an existing user", |
| 574 | Long: "Display information about an existing user.", |
| 575 | Example: ` auth0 users show |
| 576 | auth0 users show <user-id> |
| 577 | auth0 users show <user-id> --json |
| 578 | auth0 users show <user-id> --json-compact`, |
| 579 | RunE: func(cmd *cobra.Command, args []string) error { |
| 580 | if len(args) == 0 { |
| 581 | if err := userID.Ask(cmd, &inputs.ID); err != nil { |
| 582 | return err |
| 583 | } |
| 584 | } else { |
| 585 | inputs.ID = args[0] |
| 586 | } |
| 587 | |
| 588 | user := &management.User{ID: &inputs.ID} |
| 589 | |
| 590 | if err := ansi.Waiting(func() error { |
| 591 | var err error |
| 592 | user, err = cli.api.User.Read(cmd.Context(), inputs.ID) |
| 593 | return err |
| 594 | }); err != nil { |
| 595 | return fmt.Errorf("failed to load user with ID %q: %w", inputs.ID, err) |
| 596 | } |
| 597 | |
| 598 | // Get the current connection. |
| 599 | conn := stringSliceToCommaSeparatedString(cli.getUserConnection(user)) |
| 600 | user.Connection = auth0.String(conn) |
| 601 | |
| 602 | // Parse the connection name to get the requireUsername status. |
| 603 | u := cli.getConnReqUsername(cmd.Context(), auth0.StringValue(user.Connection)) |
| 604 | requireUsername := auth0.BoolValue(u) |
| 605 | |
| 606 | cli.renderer.UserShow(user, requireUsername) |
| 607 | |
| 608 | if auth0.BoolValue(user.Blocked) && !cli.json { |
| 609 | cli.renderer.Newline() |
| 610 | cli.renderer.Warnf("This user is %s and cannot authenticate.\n", ansi.BrightRed("blocked")) |
| 611 | } |
| 612 | |
| 613 | return nil |
| 614 | }, |
| 615 | } |
| 616 | |
| 617 | cmd.Flags().BoolVar(&cli.json, "json", false, "Output in json format.") |
| 618 | cmd.Flags().BoolVar(&cli.jsonCompact, "json-compact", false, "Output in compact json format.") |
| 619 | |
| 620 | return cmd |
| 621 | } |
| 622 |
no test coverage detected