Skip to content

Commit

Permalink
check err of Scanln
Browse files Browse the repository at this point in the history
  • Loading branch information
bitte-ein-bit committed May 28, 2024
1 parent 1f4b9be commit 69ed71b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ If no app is specified, the selected app (if configured) will be assumed.`,
log.Log.Fatalf("Could not get provider type for provider '%s'", provider)
}

log.Log.Infof("Getting credentials for app '%s' using provider '%s' (type: %s)" , app, provider, pType)
log.Log.Infof("Getting credentials for app '%s' using provider '%s' (type: %s)", app, provider, pType)

// allow preferred "arn" to be specified in the config file for each app
// if this is not specified the value will be empty ("")
Expand Down
5 changes: 4 additions & 1 deletion okta/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ func Get(app, provider, pArn, awsRegion string, duration int32, interactive bool
if user == "" {
// Get credentials from the user
fmt.Print("Okta username: ")
fmt.Scanln(&user)
_, err = fmt.Scanln(&user)
if err != nil {
return nil, fmt.Errorf("reading username: %v", err)
}
}

pass, err := keyChain.Get(provider)
Expand Down
11 changes: 9 additions & 2 deletions onelogin/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ func Get(app, provider, pArn, awsRegion string, duration int32, interactive bool
log.Log.Trace("No username provided")
// Get credentials from the user
fmt.Print("OneLogin username: ")
fmt.Scanln(&user)
_, err = fmt.Scanln(&user)
if err != nil {
return nil, fmt.Errorf("reading username: %v", err)
}

}

pass, err := keyChain.Get(provider)
Expand Down Expand Up @@ -190,7 +194,10 @@ func Get(app, provider, pArn, awsRegion string, duration int32, interactive bool
// Push failed or not supported by the selected MFA device
fmt.Print("Please enter the OTP from your MFA device: ")
var otp string
fmt.Scanln(&otp)
_, err = fmt.Scanln(&otp)
if err != nil {
return nil, fmt.Errorf("reading OTP: %v", err)
}

// Verify MFA
pMfa := VerifyFactorParams{
Expand Down

0 comments on commit 69ed71b

Please sign in to comment.