Skip to content

Commit

Permalink
Use old TOTP flags if the new ones are unset
Browse files Browse the repository at this point in the history
  • Loading branch information
speatzle committed Mar 26, 2024
1 parent 1229ad7 commit e0469a1
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion util/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"net/http"
"os"
"strings"
"time"

"github.com/passbolt/go-passbolt/api"
"github.com/passbolt/go-passbolt/helper"
Expand Down Expand Up @@ -123,7 +124,18 @@ func GetClient(ctx context.Context) (*api.Client, error) {
return http.Cookie{}, fmt.Errorf("Failed MFA Challenge 3 times: %w", err)
}
case "noninteractive-totp":
helper.AddMFACallbackTOTP(client, viper.GetUint("mfaRetrys"), viper.GetDuration("mfaDelay"), viper.GetDuration("totpOffset"), viper.GetString("totpToken"))
// if new flag is unset, use old flag instead
totpToken := viper.GetString("mfaTotpToken")
if totpToken == "" {
totpToken = viper.GetString("totpToken")
}

totpOffset := viper.GetDuration("mfaTotpOffset")
if totpOffset == time.Duration(0) {
totpOffset = viper.GetDuration("totpOffset")
}

helper.AddMFACallbackTOTP(client, viper.GetUint("mfaRetrys"), viper.GetDuration("mfaDelay"), totpOffset, totpToken)
case "none":
default:
}
Expand Down

0 comments on commit e0469a1

Please sign in to comment.