Skip to content

Commit c8ad9cd

Browse files
fix: save config before authentication (matching old dialog behavior)
- Login handler now saves config and updates LS before authenticating - __ideLogin__ can accept config JSON to save before auth
1 parent 05fbde3 commit c8ad9cd

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/main/kotlin/io/snyk/plugin/ui/jcef/SaveConfigHandler.kt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,17 @@ class SaveConfigHandler(
4646
JBCefJSQuery.Response("success")
4747
}
4848

49-
loginQuery.addHandler {
49+
loginQuery.addHandler { jsonConfig ->
50+
// Save config first (like the old dialog does before authentication)
51+
try {
52+
if (jsonConfig.isNotBlank() && jsonConfig != "login") {
53+
parseAndSaveConfig(jsonConfig)
54+
}
55+
} catch (e: Exception) {
56+
logger.warn("Error saving config before login", e)
57+
}
5058
runInBackground("Snyk: authenticating...") {
59+
LanguageServerWrapper.getInstance(project).updateConfiguration(true)
5160
getSnykCliAuthenticationService(project)?.authenticate()
5261
}
5362
JBCefJSQuery.Response("success")
@@ -70,7 +79,7 @@ class SaveConfigHandler(
7079
}
7180
window.__ideSaveConfig__ = function(value) { ${saveConfigQuery.inject("value")} };
7281
window.__ideNotifyModified__ = function() { ${notifyModifiedQuery.inject("'modified'")} };
73-
window.__ideLogin__ = function() { ${loginQuery.inject("'login'")} };
82+
window.__ideLogin__ = function(configJson) { ${loginQuery.inject("configJson || 'login'")} };
7483
window.__ideLogout__ = function() { ${logoutQuery.inject("'logout'")} };
7584
})();
7685
"""

0 commit comments

Comments
 (0)