Skip to content

Commit b20c10d

Browse files
mrubensroomote[bot]brunobergher
committed
Let people paste in the auth redirect url (#7805)
Co-authored-by: roomote[bot] <219738659+roomote[bot]@users.noreply.github.com> Co-authored-by: Bruno Bergher <[email protected]>
1 parent 66fb77b commit b20c10d

39 files changed

+428
-39
lines changed

src/core/webview/webviewMessageHandler.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2251,6 +2251,48 @@ export const webviewMessageHandler = async (
22512251

22522252
break
22532253
}
2254+
case "rooCloudManualUrl": {
2255+
try {
2256+
if (!message.text) {
2257+
vscode.window.showErrorMessage(t("common:errors.manual_url_empty"))
2258+
break
2259+
}
2260+
2261+
// Parse the callback URL to extract parameters
2262+
const callbackUrl = message.text.trim()
2263+
const uri = vscode.Uri.parse(callbackUrl)
2264+
2265+
if (!uri.query) {
2266+
throw new Error(t("common:errors.manual_url_no_query"))
2267+
}
2268+
2269+
const query = new URLSearchParams(uri.query)
2270+
const code = query.get("code")
2271+
const state = query.get("state")
2272+
const organizationId = query.get("organizationId")
2273+
2274+
if (!code || !state) {
2275+
throw new Error(t("common:errors.manual_url_missing_params"))
2276+
}
2277+
2278+
// Reuse the existing authentication flow
2279+
await CloudService.instance.handleAuthCallback(
2280+
code,
2281+
state,
2282+
organizationId === "null" ? null : organizationId,
2283+
)
2284+
2285+
await provider.postStateToWebview()
2286+
} catch (error) {
2287+
provider.log(`ManualUrl#handleAuthCallback failed: ${error}`)
2288+
const errorMessage = error instanceof Error ? error.message : t("common:errors.manual_url_auth_failed")
2289+
2290+
// Show error message through VS Code UI
2291+
vscode.window.showErrorMessage(`${t("common:errors.manual_url_auth_error")}: ${errorMessage}`)
2292+
}
2293+
2294+
break
2295+
}
22542296

22552297
case "saveCodeIndexSettingsAtomic": {
22562298
if (!message.codeIndexSettings) {

src/i18n/locales/ca/common.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/i18n/locales/de/common.json

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/i18n/locales/en/common.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,12 @@
106106
},
107107
"api": {
108108
"invalidKeyInvalidChars": "API key contains invalid characters."
109-
}
109+
},
110+
"manual_url_empty": "Please enter a valid callback URL",
111+
"manual_url_no_query": "Invalid callback URL: missing query parameters",
112+
"manual_url_missing_params": "Invalid callback URL: missing required parameters (code and state)",
113+
"manual_url_auth_failed": "Manual URL authentication failed",
114+
"manual_url_auth_error": "Authentication failed"
110115
},
111116
"warnings": {
112117
"no_terminal_content": "No terminal content selected",

src/i18n/locales/es/common.json

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/i18n/locales/fr/common.json

Lines changed: 11 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/i18n/locales/hi/common.json

Lines changed: 11 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/i18n/locales/id/common.json

Lines changed: 11 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/i18n/locales/it/common.json

Lines changed: 11 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/i18n/locales/ja/common.json

Lines changed: 11 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)