Skip to content

Commit

Permalink
Fix verified device OTP
Browse files Browse the repository at this point in the history
  • Loading branch information
tillson committed May 10, 2020
1 parent b0649bc commit 59a6153
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
3 changes: 0 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,6 @@ github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/y
github.com/spf13/viper v1.6.3 h1:pDDu1OyEDTKzpJwdq4TiuLyMsUgRa/BT5cn5O62NoHs=
github.com/spf13/viper v1.6.3/go.mod h1:jUMtyi0/lB5yZH/FjyGAoH7IMNrIhlBf6pXZmbMDvzw=
github.com/src-d/gcfg v1.4.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jWoI=
github.com/src-d/go-git v4.7.0+incompatible h1:IYSSnbAHeKmsfbQFi9ozbid+KNh0bKjlorMfQehQbcE=
github.com/src-d/go-git v4.7.0+incompatible/go.mod h1:1bQciz+hn0jzPQNsYj0hDFZHLJBdV7gXE2mWhC7EkFk=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
Expand Down Expand Up @@ -227,7 +225,6 @@ gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
gopkg.in/src-d/go-billy.v4 v4.3.2/go.mod h1:nDjArDMp+XMs1aFAESLRjfGSgfvoYN0hDfzEk0GjC98=
gopkg.in/src-d/go-git-fixtures.v3 v3.5.0/go.mod h1:dLBcvytrw/TYZsNTWCnkNF2DSIlzWYqTe3rJR56Ac7g=
gopkg.in/src-d/go-git.v4 v4.13.1 h1:SRtFyV8Kxc0UP7aCHcijOMQGPxHSmMOPrzulQWolkYE=
gopkg.in/src-d/go-git.v4 v4.13.1/go.mod h1:nx5NYcxdKxq5fpltdHnPa2Exj4Sx0EclMWZQbYDu2z8=
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
Expand Down
23 changes: 17 additions & 6 deletions internal/app/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,27 @@ func LoginToGitHub(credentials GitHubCredentials) (httpClient *http.Client, err
if err != nil {
log.Fatalf("can't open /dev/tty: %s", err)
}
fmt.Println(resp.Request.URL)
return nil, nil
fmt.Printf("Enter your GitHub 2FA code: ")
scanner := bufio.NewScanner(tty)
_ = scanner.Scan()
otp := scanner.Text()
resp, err = client.PostForm("https://github.com/sessions/two-factor", url.Values{

"authenticity_token": {csrf},
"otp": {otp},
})
data, err = ioutil.ReadAll(resp.Body)
if strings.Index(resp.Request.URL.String(), "verified-device") > -1 {
resp, err = client.PostForm("https://github.com/sessions/verified-device", url.Values{

"authenticity_token": {csrf},
"otp": {otp},
})
data, err = ioutil.ReadAll(resp.Body)
} else {
resp, err = client.PostForm("https://github.com/sessions/two-factor", url.Values{

"authenticity_token": {csrf},
"otp": {otp},
})
data, err = ioutil.ReadAll(resp.Body)
}
// fmt.Println(string(data))
}

Expand Down

0 comments on commit 59a6153

Please sign in to comment.