summaryrefslogtreecommitdiffstats
path: root/pkg/gui/credentials_panel.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2022-02-23 19:44:48 +1100
committerJesse Duffield <jessedduffield@gmail.com>2022-03-17 19:13:40 +1100
commit46e9946854086f170ec01f12daf075e197e420f7 (patch)
tree93ef30013ddde640da6a71f0037a1147e712337b /pkg/gui/credentials_panel.go
parentd0805616e410bdf37f42737782cdc309ef1dd17a (diff)
refactor credential handling
Diffstat (limited to 'pkg/gui/credentials_panel.go')
-rw-r--r--pkg/gui/credentials_panel.go57
1 files changed, 0 insertions, 57 deletions
diff --git a/pkg/gui/credentials_panel.go b/pkg/gui/credentials_panel.go
deleted file mode 100644
index ba654e0eb..000000000
--- a/pkg/gui/credentials_panel.go
+++ /dev/null
@@ -1,57 +0,0 @@
-package gui
-
-import (
- "strings"
-
- "github.com/jesseduffield/lazygit/pkg/commands/oscommands"
- "github.com/jesseduffield/lazygit/pkg/gui/types"
-)
-
-type credentials chan string
-
-// promptUserForCredential wait for a username, password or passphrase input from the credentials popup
-func (gui *Gui) promptUserForCredential(passOrUname oscommands.CredentialType) string {
- gui.credentials = make(chan string)
- gui.OnUIThread(func() error {
- credentialsView := gui.Views.Credentials
- switch passOrUname {
- case oscommands.Username:
- credentialsView.Title = gui.c.Tr.CredentialsUsername
- credentialsView.Mask = 0
- case oscommands.Password:
- credentialsView.Title = gui.c.Tr.CredentialsPassword
- credentialsView.Mask = '*'
- case oscommands.Passphrase:
- credentialsView.Title = gui.c.Tr.CredentialsPassphrase
- credentialsView.Mask = '*'
- }
-
- if err := gui.c.PushContext(gui.State.Contexts.Credentials); err != nil {
- return err
- }
-
- return nil
- })
-
- // wait for username/passwords/passphrase input
- userInput := <-gui.credentials
- return userInput + "\n"
-}
-
-func (gui *Gui) handleSubmitCredential() error {
- credentialsView := gui.Views.Credentials
- message := strings.TrimSpace(credentialsView.TextArea.GetContent())
- gui.credentials <- message
- credentialsView.ClearTextArea()
- if err := gui.c.PopContext(); err != nil {
- return err
- }
-
- return gui.c.Refresh(types.RefreshOptions{Mode: types.ASYNC})
-}
-
-func (gui *Gui) handleCloseCredentialsView() error {
- gui.Views.Credentials.ClearTextArea()
- gui.credentials <- ""
- return gui.c.PopContext()
-}