From 803bcfcfb9c357b8ca05c2ebd51840ec35b5ebad Mon Sep 17 00:00:00 2001 From: Ilya Shcherbak Date: Sun, 15 Nov 2026 14:10:21 +0300 Subject: [PATCH] Identify Wizard as the source of Hub signup and login --- crates/wizard-core/src/hub/login.rs | 23 +++++++++++++++---- crates/wizard-gui/src/hub_auth.rs | 2 +- .../wizard-ui/src/settings/HubSignIn.tsx | 2 +- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/crates/wizard-core/src/hub/login.rs b/crates/wizard-core/src/hub/login.rs index de0d42d..49e58cf 100644 --- a/crates/wizard-core/src/hub/login.rs +++ b/crates/wizard-core/src/hub/login.rs @@ -102,10 +102,12 @@ impl CallbackServer { pub fn authorization_url(&self) -> Url { let mut url = Url::parse(&format!("{HUB_ORIGIN}{AUTHORIZATION_PATH}")) .expect("Hub authorization URL is valid"); - url.query_pairs_mut().append_pair( - CALLBACK_PARAMETER, - &format!("http://{}{CALLBACK_PATH}", self.address), - ); + url.query_pairs_mut() + .append_pair("source", "wizard") + .append_pair( + CALLBACK_PARAMETER, + &format!("http://{}{CALLBACK_PATH}", self.address), + ); url } @@ -368,4 +370,17 @@ mod tests { Some("https://hub.coreinfra.ai/hub/api/login?key=test") ); } + + #[tokio::test] + async fn browser_login_identifies_wizard_and_preserves_callback() { + let server = CallbackServer::bind().await.expect("callback listener"); + let url = server.authorization_url(); + assert_eq!(url.path(), "/app-login"); + let params: std::collections::HashMap<_, _> = url.query_pairs().collect(); + assert_eq!(params.get("source").map(AsRef::as_ref), Some("wizard")); + assert_eq!( + params.get("callback_url").map(AsRef::as_ref), + Some(format!("http://{}/callback", server.address).as_str()) + ); + } } diff --git a/crates/wizard-gui/src/hub_auth.rs b/crates/wizard-gui/src/hub_auth.rs index 158b1ad..f981565 100644 --- a/crates/wizard-gui/src/hub_auth.rs +++ b/crates/wizard-gui/src/hub_auth.rs @@ -271,7 +271,7 @@ pub(crate) async fn open_hub(app: tauri::AppHandle, theme: String) -> Result<(), /// Opens the registration page in the system browser, leaving Wizard open. #[tauri::command] pub(crate) async fn open_hub_registration() -> Result<(), String> { - let url = Url::parse("https://hub.coreinfra.ai/register") + let url = Url::parse("https://hub.coreinfra.ai/register?source=wizard") .map_err(|_| "Некорректный адрес регистрации")?; login::open_browser(&url) .await diff --git a/crates/wizard-gui/wizard-ui/src/settings/HubSignIn.tsx b/crates/wizard-gui/wizard-ui/src/settings/HubSignIn.tsx index 5cc762f..73339b0 100644 --- a/crates/wizard-gui/wizard-ui/src/settings/HubSignIn.tsx +++ b/crates/wizard-gui/wizard-ui/src/settings/HubSignIn.tsx @@ -54,7 +54,7 @@ export function HubSignIn({ hub }: { hub: HubAccountControl }) { {pending ? "После входа вернитесь в Wizard — аккаунт подключится автоматически." : <>Wizard установлен, теперь войдите в аккаунт хаба, если аккаунта нет – { event.preventDefault(); hub.register(); }}