(cli *cli)
| 77 | } |
| 78 | |
| 79 | func deleteUserBlocksCmd(cli *cli) *cobra.Command { |
| 80 | cmd := &cobra.Command{ |
| 81 | Use: "unblock", |
| 82 | Short: "Remove brute-force protection blocks for users", |
| 83 | Long: "Remove brute-force protection blocks for users by user ID, username, phone number or email.", |
| 84 | Example: ` auth0 users blocks unblock <user-id1|username1|email1|phone-number1> <user-id2|username2|email2|phone-number2> |
| 85 | auth0 users blocks unblock "auth0|61b5b6e90783fa19f7c57dad" |
| 86 | auth0 users blocks unblock "frederik@travel0.com" "poovam@travel0.com" |
| 87 | `, |
| 88 | RunE: func(cmd *cobra.Command, args []string) error { |
| 89 | var ids []string |
| 90 | if len(args) == 0 { |
| 91 | var id string |
| 92 | if err := userIdentifier.Ask(cmd, &id); err != nil { |
| 93 | return err |
| 94 | } |
| 95 | ids = append(ids, id) |
| 96 | } else { |
| 97 | ids = args |
| 98 | } |
| 99 | |
| 100 | return ansi.ProgressBar("Unblocking user(s)", ids, func(_ int, id string) error { |
| 101 | if id != "" { |
| 102 | err := cli.api.User.Unblock(cmd.Context(), id) |
| 103 | if mErr, ok := err.(management.Error); ok && mErr.Status() != http.StatusBadRequest { |
| 104 | return fmt.Errorf("failed to unblock user with identifier %s: %w", id, err) |
| 105 | } |
| 106 | |
| 107 | err = cli.api.User.UnblockByIdentifier(cmd.Context(), id) |
| 108 | if err != nil { |
| 109 | return fmt.Errorf("failed to unblock user with identifier %s: %w", id, err) |
| 110 | } |
| 111 | } |
| 112 | return nil |
| 113 | }) |
| 114 | }, |
| 115 | } |
| 116 | |
| 117 | return cmd |
| 118 | } |
no test coverage detected