mirror of
https://github.com/c0re100/gotdlib.git
synced 2026-02-21 20:20:17 +01:00
Implement terminal style password input
This commit is contained in:
parent
7196ad9adc
commit
cc7712e2c4
3 changed files with 22 additions and 3 deletions
|
|
@ -3,7 +3,10 @@ package client
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
)
|
||||
|
||||
var ErrNotSupportedAuthorizationState = errors.New("not supported state")
|
||||
|
|
@ -150,10 +153,13 @@ func CliInteractor(clientAuthorizer *clientAuthorizer) {
|
|||
|
||||
case TypeAuthorizationStateWaitPassword:
|
||||
fmt.Println("Enter password: ")
|
||||
var password string
|
||||
fmt.Scanln(&password)
|
||||
bytePassword, err := terminal.ReadPassword(int(syscall.Stdin))
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
continue
|
||||
}
|
||||
|
||||
clientAuthorizer.Password <- password
|
||||
clientAuthorizer.Password <- string(bytePassword)
|
||||
|
||||
case TypeAuthorizationStateReady:
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue