diff options
author | Amine Hilaly <hilalyamine@gmail.com> | 2019-08-30 23:20:46 +0200 |
---|---|---|
committer | Amine Hilaly <hilalyamine@gmail.com> | 2019-09-01 00:04:01 +0200 |
commit | 46f957344499863c97a20d34cf8ba078d3245c3a (patch) | |
tree | 724312b5c3e232e867745e3d522e4cf28384b91a /bridge | |
parent | c5824ff1b44fe7005028a9e60161bf37ab658ecc (diff) | |
download | git-bug-46f957344499863c97a20d34cf8ba078d3245c3a.tar.gz |
bridge/github: move cleaners to where is called
Diffstat (limited to 'bridge')
-rw-r--r-- | bridge/github/config.go | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/bridge/github/config.go b/bridge/github/config.go index d1b57e10..bc4911e0 100644 --- a/bridge/github/config.go +++ b/bridge/github/config.go @@ -237,16 +237,6 @@ func promptTokenOptions(owner, project string) (string, error) { return promptToken() } - // Register restore state cleaner before prompting passwords inputs - termState, err := terminal.GetState(int(syscall.Stdin)) - if err != nil { - return "", err - } - - interrupt.RegisterCleaner(func() error { - return terminal.Restore(int(syscall.Stdin), termState) - }) - return loginAndRequestToken(owner, project) } } @@ -526,6 +516,16 @@ func validateProject(owner, project, token string) (bool, error) { } func promptPassword() (string, error) { + termState, err := terminal.GetState(int(syscall.Stdin)) + if err != nil { + return "", err + } + + cancel := interrupt.RegisterCleaner(func() error { + return terminal.Restore(int(syscall.Stdin), termState) + }) + defer cancel() + for { fmt.Print("password: ") @@ -547,6 +547,16 @@ func promptPassword() (string, error) { } func prompt2FA() (string, error) { + termState, err := terminal.GetState(int(syscall.Stdin)) + if err != nil { + return "", err + } + + cancel := interrupt.RegisterCleaner(func() error { + return terminal.Restore(int(syscall.Stdin), termState) + }) + defer cancel() + for { fmt.Print("two-factor authentication code: ") |