Skip to content

Commit

Permalink
fix: update environment correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
bastiandoetsch committed Jul 4, 2024
1 parent 3ae1d53 commit bed19e3
Showing 1 changed file with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,18 @@ private void setupProcessBuilderBase(ProcessBuilder pb) {

String token = Preferences.getInstance().getAuthToken();
if (token != null && !token.isBlank()) {
try {
ObjectMapper objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
var oauthToken = objectMapper.readValue(token, OAuthToken.class);
pb.environment().put(EnvironmentConstants.ENV_OAUTH_ACCESS_TOKEN, oauthToken.getAccessToken());
pb.environment().remove(EnvironmentConstants.ENV_SNYK_TOKEN);
} catch (Exception e) {
SnykLogger.logError(e);
if (Preferences.getInstance().getBooleanPref(Preferences.USE_TOKEN_AUTH, false)) {
pb.environment().put(EnvironmentConstants.ENV_SNYK_TOKEN, token);
pb.environment().remove(EnvironmentConstants.ENV_OAUTH_ACCESS_TOKEN);
} else {
try {
ObjectMapper objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
var oauthToken = objectMapper.readValue(token, OAuthToken.class);
pb.environment().put(EnvironmentConstants.ENV_OAUTH_ACCESS_TOKEN, oauthToken.getAccessToken());
pb.environment().remove(EnvironmentConstants.ENV_SNYK_TOKEN);
} catch (Exception e) {
SnykLogger.logInfo(token);
}
}
}

Expand Down

0 comments on commit bed19e3

Please sign in to comment.