From 5a14508178026d1c9ce0ba5e443c14b42d197215 Mon Sep 17 00:00:00 2001 From: Deepak Bhagat Date: Tue, 7 Apr 2026 02:00:38 +0530 Subject: [PATCH] fix(auth): reject OAuth promise when popup is closed without completing login --- packages/auth/src/loginWithRocketChatOAuth.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/auth/src/loginWithRocketChatOAuth.ts b/packages/auth/src/loginWithRocketChatOAuth.ts index 955e70c7a4..ce3c701c7a 100644 --- a/packages/auth/src/loginWithRocketChatOAuth.ts +++ b/packages/auth/src/loginWithRocketChatOAuth.ts @@ -42,7 +42,7 @@ const loginWithRocketChatOAuth = async (config: { api: Api }) => { width=800,height=600,left=-1000,top=-1000,rel=opener`; const popup = window.open(authorizeUrl, "Login", params); - return new Promise((resolve) => { + return new Promise((resolve, reject) => { if (popup) { const onMessage = async (e: MessageEvent) => { if (e.data.type === "rc-oauth-callback") { @@ -61,6 +61,7 @@ width=800,height=600,left=-1000,top=-1000,rel=opener`; if (popup.closed) { clearInterval(checkInterval); window.removeEventListener("message", onMessage); + reject(new Error("OAuth login cancelled")); } }, 1000); } else {