Skip to content

Commit

Permalink
[#160] allow jira logout to delete your api-token from keychain
Browse files Browse the repository at this point in the history
  • Loading branch information
coryb committed Apr 3, 2018
1 parent 4b9873b commit bd3cf99
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions jiracmd/logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/coryb/figtree"
"github.com/coryb/oreo"
"github.com/mgutz/ansi"
survey "gopkg.in/AlecAivazis/survey.v1"
"gopkg.in/Netflix-Skunkworks/go-jira.v1"
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
kingpin "gopkg.in/alecthomas/kingpin.v2"
Expand All @@ -29,6 +30,24 @@ func CmdLogoutRegistry() *jiracli.CommandRegistryEntry {
func CmdLogout(o *oreo.Client, globals *jiracli.GlobalOptions, opts *jiracli.CommonOptions) error {
if globals.AuthMethod() == "api-token" {
log.Noticef("No need to logout when using api-token authentication method")
if globals.GetPass() != "" {
delete := false
err := survey.AskOne(
&survey.Confirm{
Message: fmt.Sprintf("Delete api-token from password provider [%s]: ", globals.PasswordSource),
Default: false,
},
&delete,
nil,
)
if err != nil {
log.Errorf("%s", err)
panic(jiracli.Exit{Code: 1})
}
if delete {
globals.SetPass("")
}
}
return nil
}
ua := o.WithoutRedirect().WithRetries(0).WithoutCallbacks()
Expand Down

0 comments on commit bd3cf99

Please sign in to comment.