-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DXCDT-333: Nest users unblock under users blocks unblock (#617)
- Loading branch information
Showing
14 changed files
with
137 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
layout: default | ||
--- | ||
# auth0 users blocks unblock | ||
|
||
Remove brute-force protection blocks for a given user. | ||
|
||
## Usage | ||
``` | ||
auth0 users blocks unblock [flags] | ||
``` | ||
|
||
## Examples | ||
|
||
``` | ||
auth0 users blocks unblock <user-id> | ||
``` | ||
|
||
|
||
|
||
|
||
## InheritedFlags | ||
|
||
``` | ||
--debug Enable debug mode. | ||
--no-color Disable colors. | ||
--no-input Disable interactivity. | ||
--tenant string Specific tenant to use. | ||
``` | ||
|
||
|
||
## Related Commands | ||
|
||
- [auth0 users blocks list](auth0_users_blocks_list.md) - List brute-force protection blocks for a given user | ||
- [auth0 users blocks unblock](auth0_users_blocks_unblock.md) - Remove brute-force protection blocks for a given user | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package cli | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/auth0/go-auth0/management" | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/auth0/auth0-cli/internal/ansi" | ||
) | ||
|
||
func userBlocksCmd(cli *cli) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "blocks", | ||
Short: "Manage brute-force protection user blocks", | ||
Long: "Manage brute-force protection user blocks.", | ||
} | ||
|
||
cmd.SetUsageTemplate(resourceUsageTemplate()) | ||
cmd.AddCommand(listUserBlocksCmd(cli)) | ||
cmd.AddCommand(deleteUserBlocksCmd(cli)) | ||
|
||
return cmd | ||
} | ||
|
||
func listUserBlocksCmd(cli *cli) *cobra.Command { | ||
var inputs struct { | ||
userID string | ||
} | ||
|
||
cmd := &cobra.Command{ | ||
Use: "list", | ||
Args: cobra.MaximumNArgs(1), | ||
Short: "List brute-force protection blocks for a given user", | ||
Long: "List brute-force protection blocks for a given user.", | ||
Example: ` auth0 users blocks list <user-id> | ||
auth0 users blocks list <user-id> --json`, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
if len(args) == 0 { | ||
if err := userID.Ask(cmd, &inputs.userID); err != nil { | ||
return err | ||
} | ||
} else { | ||
inputs.userID = args[0] | ||
} | ||
|
||
var userBlocks []*management.UserBlock | ||
err := ansi.Waiting(func() (err error) { | ||
userBlocks, err = cli.api.User.Blocks(inputs.userID) | ||
return err | ||
}) | ||
if err != nil { | ||
return fmt.Errorf("failed to list user blocks for user with ID %s: %w", inputs.userID, err) | ||
} | ||
|
||
cli.renderer.UserBlocksList(userBlocks) | ||
return nil | ||
}, | ||
} | ||
|
||
cmd.Flags().BoolVar(&cli.json, "json", false, "Output in json format.") | ||
|
||
return cmd | ||
} | ||
|
||
func deleteUserBlocksCmd(cli *cli) *cobra.Command { | ||
var inputs struct { | ||
userID string | ||
} | ||
|
||
cmd := &cobra.Command{ | ||
Use: "unblock", | ||
Args: cobra.MaximumNArgs(1), | ||
Short: "Remove brute-force protection blocks for a given user", | ||
Long: "Remove brute-force protection blocks for a given user.", | ||
Example: ` auth0 users blocks unblock <user-id>`, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
if len(args) == 0 { | ||
if err := userID.Ask(cmd, &inputs.userID); err != nil { | ||
return err | ||
} | ||
} else { | ||
inputs.userID = args[0] | ||
} | ||
|
||
err := ansi.Spinner("Unblocking user...", func() error { | ||
return cli.api.User.Unblock(inputs.userID) | ||
}) | ||
if err != nil { | ||
return fmt.Errorf("failed to unblock user with ID %s: %w", inputs.userID, err) | ||
} | ||
|
||
return nil | ||
}, | ||
} | ||
|
||
return cmd | ||
} |