Skip to content
This repository has been archived by the owner on May 18, 2021. It is now read-only.

Commit

Permalink
MFA input validation (#139)
Browse files Browse the repository at this point in the history
Addressing some possible confusion around current “index out of range” runtime errors when selecting an MFA option.
  • Loading branch information
nickatsegment authored Apr 2, 2019
1 parent 00408a7 commit b1140c3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/okta.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,19 @@ func (o *OktaClient) selectMFADevice() (*OktaUserAuthnFactor, error) {
log.Infof("%d: %s (%s)", i, f.Provider, f.FactorType)
}
i, err := Prompt("Select MFA method", false)
if i == "" {
return nil, errors.New("Invalid selection - Please use an option that is listed")
}
if err != nil {
return nil, err
}
factorIdx, err := strconv.Atoi(i)
if err != nil {
return nil, err
}
if factorIdx > (len(factors) - 1) {
return nil, errors.New("Invalid selection - Please use an option that is listed")
}
return &factors[factorIdx], nil
}

Expand Down

0 comments on commit b1140c3

Please sign in to comment.