Skip to content

Commit

Permalink
Merge pull request #205 from converge/fix__186
Browse files Browse the repository at this point in the history
fix user access token deletion (fix #186)
  • Loading branch information
silvin-lubecki authored Apr 14, 2022
2 parents c9cb0ac + 481b71e commit 0fee32c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
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

0 comments on commit 0fee32c

Please sign in to comment.