mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 17:27:40 +00:00
Fix: Do not save duplicate domains
This commit is contained in:
@@ -604,11 +604,14 @@ func askForDomain() error {
|
|||||||
config.INFISICAL_LOGIN_URL = fmt.Sprintf("%s/login", domain)
|
config.INFISICAL_LOGIN_URL = fmt.Sprintf("%s/login", domain)
|
||||||
|
|
||||||
// Write the new domain to the config file, to allow the user to select it in the future if needed
|
// Write the new domain to the config file, to allow the user to select it in the future if needed
|
||||||
infisicalConfig.Domains = append(infisicalConfig.Domains, domain)
|
// First check if infiscialConfig.Domains already includes the domain, if it does, do not add it again
|
||||||
err = util.WriteConfigFile(&infisicalConfig)
|
if !util.ArrayContains(infisicalConfig.Domains, domain) {
|
||||||
|
infisicalConfig.Domains = append(infisicalConfig.Domains, domain)
|
||||||
|
err = util.WriteConfigFile(&infisicalConfig)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("askForDomain: unable to write domains to config file because [err=%s]", err)
|
return fmt.Errorf("askForDomain: unable to write domains to config file because [err=%s]", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -298,3 +298,12 @@ func GenerateRandomString(length int) string {
|
|||||||
}
|
}
|
||||||
return string(b)
|
return string(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ArrayContains(arr []string, val string) bool {
|
||||||
|
for _, item := range arr {
|
||||||
|
if item == val {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user