Skip to content

Commit

Permalink
delete backup secrets when new user login
Browse files Browse the repository at this point in the history
  • Loading branch information
maidul98 committed Feb 4, 2023
1 parent e16c0e5 commit 1e9118d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cli/packages/cmd/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ var loginCmd = &cobra.Command{
util.HandleError(err, "Unable to write write to Infisical Config file. Please try again")
}

// clear backed up secrets from prev account
util.DeleteBackupSecrets()

color.Green("Nice! You are logged in as: %v", email)

},
Expand Down
13 changes: 13 additions & 0 deletions cli/packages/util/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,3 +411,16 @@ func ReadBackupSecrets(workspace string, environment string, encryptionKey []byt
return plainTextSecrets, nil

}

func DeleteBackupSecrets() error {
secrets_backup_folder_name := "secrets-backup"

_, fullConfigFileDirPath, err := GetFullConfigFilePath()
if err != nil {
return fmt.Errorf("ReadBackupSecrets: unable to write config file because an error occurred when getting config file path [err=%s]", err)
}

fullPathToSecretsBackupFolder := fmt.Sprintf("%s/%s", fullConfigFileDirPath, secrets_backup_folder_name)

return os.RemoveAll(fullPathToSecretsBackupFolder)
}

0 comments on commit 1e9118d

Please sign in to comment.