aboutsummaryrefslogtreecommitdiffstats
path: root/bridge/github
diff options
context:
space:
mode:
authorAmine Hilaly <hilalyamine@gmail.com>2019-06-05 01:42:36 +0200
committerAmine Hilaly <hilalyamine@gmail.com>2019-06-07 01:17:59 +0200
commita6c8b6b78dcf9b31c73fe35545e3fb754e06851a (patch)
treeb9b86262f478be9a0d4c65fbb4a17f7f0bb75e05 /bridge/github
parentc52a467302608012c4fd7d496a7cd60ad153b5cd (diff)
downloadgit-bug-a6c8b6b78dcf9b31c73fe35545e3fb754e06851a.tar.gz
make token visible in configuration process
validate token global fixes
Diffstat (limited to 'bridge/github')
-rw-r--r--bridge/github/config.go28
1 files changed, 16 insertions, 12 deletions
diff --git a/bridge/github/config.go b/bridge/github/config.go
index b5468846..707b3e2f 100644
--- a/bridge/github/config.go
+++ b/bridge/github/config.go
@@ -197,8 +197,8 @@ func randomFingerprint() string {
func promptTokenOptions(owner, project string) (string, error) {
for {
fmt.Println()
- fmt.Println("[0]: user provided token")
- fmt.Println("[1]: interactive token creation")
+ fmt.Println("[1]: user provided token")
+ fmt.Println("[2]: interactive token creation")
fmt.Print("Select option: ")
line, err := bufio.NewReader(os.Stdin).ReadString('\n')
@@ -210,12 +210,12 @@ func promptTokenOptions(owner, project string) (string, error) {
line = strings.TrimRight(line, "\n")
index, err := strconv.Atoi(line)
- if err != nil || (index != 0 && index != 1) {
+ if err != nil || (index != 1 && index != 2) {
fmt.Println("invalid input")
continue
}
- if index == 0 {
+ if index == 1 {
return promptToken()
}
@@ -234,21 +234,25 @@ func promptToken() (string, error) {
fmt.Println(" - 'repo' : to be able to read private repositories")
fmt.Println()
+ re, err := regexp.Compile(`^[a-zA-Z0-9]{40}`)
+ if err != nil {
+ panic("regexp compile:" + err.Error())
+ }
+
for {
fmt.Print("Enter token: ")
- byteToken, err := terminal.ReadPassword(int(syscall.Stdin))
- fmt.Println()
-
+ line, err := bufio.NewReader(os.Stdin).ReadString('\n')
if err != nil {
return "", err
}
- if len(byteToken) > 0 {
- return string(byteToken), nil
+ token := strings.TrimRight(line, "\n")
+ if re.MatchString(token) {
+ return token, nil
}
- fmt.Println("token is empty")
+ fmt.Println("token is invalid")
}
}
@@ -534,8 +538,8 @@ func prompt2FA() (string, error) {
func promptProjectVisibility() (bool, error) {
for {
- fmt.Println("[0]: public")
- fmt.Println("[1]: private")
+ fmt.Println("[1]: public")
+ fmt.Println("[2]: private")
fmt.Print("repository visibility: ")
line, err := bufio.NewReader(os.Stdin).ReadString('\n')