Requested changes

This commit is contained in:
Daniel Hougaard
2024-09-18 12:50:28 +04:00
parent e7278c4cd9
commit 9234213c62
3 changed files with 24 additions and 25 deletions
+2 -21
View File
@@ -1,9 +1,6 @@
package util
import (
"fmt"
"github.com/Infisical/infisical-merge/packages/config"
"github.com/Infisical/infisical-merge/packages/models"
)
@@ -52,7 +49,6 @@ func IsAuthMethodValid(authMethod string, allowUserAuth bool) (isValid bool, str
}
func ShouldUseInfisicalToken(token *models.TokenDetails, validTokenTypes []string) bool {
if token == nil {
return false
}
@@ -63,24 +59,9 @@ func ShouldUseInfisicalToken(token *models.TokenDetails, validTokenTypes []strin
}
for _, tokenType := range validTokenTypes {
if token.Type != tokenType {
continue
if token.Type == tokenType {
return true
}
details, err := GetCurrentLoggedInUserDetails()
if err == nil && details.IsUserLoggedIn && !details.LoginExpired && !config.INFISICAL_SILENT_MODE {
var usingFrom string
if token.PassedAsFlag {
usingFrom = "--token flag"
} else {
usingFrom = "INFISICAL_TOKEN environment variable"
}
PrintWarning(fmt.Sprintf("You are currently logged in, but the command will be using the token provided from the %s.", usingFrom))
}
return true
}
return false