diff --git a/lib/okta.go b/lib/okta.go index 6485150c..03f4088d 100644 --- a/lib/okta.go +++ b/lib/okta.go @@ -278,6 +278,9 @@ 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 } @@ -285,6 +288,9 @@ func (o *OktaClient) selectMFADevice() (*OktaUserAuthnFactor, error) { 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 }