Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix user access token deletion (fix #186) #205

Merged
merged 2 commits into from
Apr 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions internal/commands/token/rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@ func runRemove(streams command.Streams, hubClient *hub.Client, opts removeOption
}

if !opts.force {

fmt.Fprintf(streams.Out(), ansi.Warn("WARNING: This action is irreversible.")+`
By confirming, you will permanently delete the access token.
Deleting a token will invalidate your credentials on all Docker clients currently authenticated with this token.
Removing the tokens will invalidate your credentials on all Docker clients currently authenticated with the tokens.

Please type your username %q to confirm deletion: `, hubClient.AuthConfig.Username)
Please type your username %q to confirm token deletion: `, hubClient.AuthConfig.Username)
reader := bufio.NewReader(streams.In())
input, _ := reader.ReadString('\n')
input = strings.ToLower(strings.TrimSpace(input))
Expand All @@ -83,6 +84,6 @@ Please type your username %q to confirm deletion: `, hubClient.AuthConfig.Userna
if err := hubClient.RemoveToken(u.String()); err != nil {
return err
}
fmt.Fprintln(streams.Out(), ansi.Emphasise("Deleted"), u)
fmt.Fprintln(streams.Out(), ansi.Emphasise("Access token deleted"), u)
return nil
}
1 change: 1 addition & 0 deletions pkg/hub/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ func WithOutStream(out io.Writer) ClientOp {
// WithHubAccount sets the current account name
func WithHubAccount(account string) ClientOp {
return func(c *Client) error {
c.AuthConfig.Username = account
c.account = account
return nil
}
Expand Down