Skip to content

Commit

Permalink
fix: issue in download dev cmd when using SMS 2-factor codes #79
Browse files Browse the repository at this point in the history
  • Loading branch information
blacktop committed Feb 15, 2022
1 parent a0b1be3 commit c6a3d7b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions internal/download/dev_portal.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ func (app *App) signIn(username, password string) error {
return err
}

phoneID := 1
codeType := "phone"

// SMS was sent automatically
Expand All @@ -379,7 +380,8 @@ func (app *App) signIn(username, password string) error {
}
return err
}
if err := app.requestCode(app.authOptions.TrustedPhoneNumbers[phoneNumber].ID); err != nil {
phoneID = app.authOptions.TrustedPhoneNumbers[phoneNumber].ID
if err := app.requestCode(phoneID); err != nil {
return err
}

Expand Down Expand Up @@ -423,7 +425,7 @@ func (app *App) signIn(username, password string) error {
}
}

if err := app.verifyCode(codeType, code); err != nil {
if err := app.verifyCode(codeType, code, phoneID); err != nil {
return err
}

Expand Down Expand Up @@ -525,13 +527,13 @@ func (app *App) requestCode(phoneID int) error {
return nil
}

func (app *App) verifyCode(codeType, code string) error {
func (app *App) verifyCode(codeType, code string, phoneID int) error {
buf := new(bytes.Buffer)

if codeType == "phone" {
json.NewEncoder(buf).Encode(&phone{
Number: phoneNumber{
ID: 1,
ID: phoneID,
},
Mode: "sms",
SecurityCode: scode{
Expand Down

0 comments on commit c6a3d7b

Please sign in to comment.