mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-03 03:25:48 +00:00
@@ -23,8 +23,5 @@ func WriteToFile(fileName string, dataToWrite []byte, filePerm os.FileMode) erro
|
||||
|
||||
func CheckIsConnectedToInternet() (ok bool) {
|
||||
_, err := http.Get("http://clients3.google.com/generate_204")
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
return err == nil
|
||||
}
|
||||
|
||||
@@ -31,9 +31,25 @@ func WriteInitalConfig(userCredentials *models.UserCredentials) error {
|
||||
return fmt.Errorf("writeInitalConfig: unable to write config file because [err=%s]", err)
|
||||
}
|
||||
|
||||
//if empty
|
||||
if existingConfigFile.LoggedInUsersEmail == nil {
|
||||
existingConfigFile.LoggedInUsersEmail = []string{}
|
||||
}
|
||||
|
||||
//if profile exists
|
||||
if len(existingConfigFile.LoggedInUsersEmail) > 0 {
|
||||
ok := Contains(existingConfigFile.LoggedInUsersEmail, userCredentials.Email)
|
||||
if !ok {
|
||||
existingConfigFile.LoggedInUsersEmail = append(existingConfigFile.LoggedInUsersEmail, userCredentials.Email)
|
||||
}
|
||||
} else {
|
||||
existingConfigFile.LoggedInUsersEmail = append(existingConfigFile.LoggedInUsersEmail, userCredentials.Email)
|
||||
}
|
||||
|
||||
configFile := models.ConfigFile{
|
||||
LoggedInUserEmail: userCredentials.Email,
|
||||
VaultBackendType: existingConfigFile.VaultBackendType,
|
||||
LoggedInUserEmail: userCredentials.Email,
|
||||
VaultBackendType: existingConfigFile.VaultBackendType,
|
||||
LoggedInUsersEmail: existingConfigFile.LoggedInUsersEmail,
|
||||
}
|
||||
|
||||
configFileMarshalled, err := json.Marshal(configFile)
|
||||
@@ -176,7 +192,7 @@ func GetConfigFile() (models.ConfigFile, error) {
|
||||
return configFile, nil
|
||||
}
|
||||
|
||||
// Write a ConfigFile to disk. Raise error if unable to save the model to ask
|
||||
// Write a ConfigFile to disk. Raise error if unable to save the model to disk
|
||||
func WriteConfigFile(configFile *models.ConfigFile) error {
|
||||
fullConfigFilePath, fullConfigFileDirPath, err := GetFullConfigFilePath()
|
||||
if err != nil {
|
||||
|
||||
@@ -61,6 +61,15 @@ func IsSecretTypeValid(s string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func Contains(iter []string, elem string) bool {
|
||||
for _, value := range iter {
|
||||
if value == elem {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func RequireLogin() {
|
||||
currentUserDetails, err := GetCurrentLoggedInUserDetails()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user