Use old TOTP flags if the new ones are unset

This commit is contained in:
Samuel Lorch 2024-03-26 11:10:08 +01:00
parent 1229ad7b59
commit e0469a14b0

View file

@ -9,6 +9,7 @@ import (
"net/http"
"os"
"strings"
"time"
"github.com/passbolt/go-passbolt/api"
"github.com/passbolt/go-passbolt/helper"
@ -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:
}