From a34df1079c58eb93aa791e94597d5f1ec2c4760e Mon Sep 17 00:00:00 2001 From: yash-rajpal Date: Wed, 25 Mar 2026 01:14:49 +0530 Subject: [PATCH 1/2] use passport OAuth redirect --- apps/meteor/client/startup/startup.ts | 9 +++++++-- .../web-ui-registration/src/LoginServicesButton.tsx | 10 +++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/apps/meteor/client/startup/startup.ts b/apps/meteor/client/startup/startup.ts index 45fa6c12b1bbb..30c4a381e9d85 100644 --- a/apps/meteor/client/startup/startup.ts +++ b/apps/meteor/client/startup/startup.ts @@ -12,8 +12,7 @@ import { watchUserId } from '../meteor/user'; Meteor.startup(() => { let status: UserStatus | undefined = undefined; Tracker.autorun(async () => { - const uid = watchUserId(); - if (!uid) { + if (Meteor.loggingOut()) { removeLocalUserData(); return; } @@ -26,6 +25,12 @@ Meteor.startup(() => { return; } + const uid = watchUserId(); + + if (!uid) { + return; + } + const user = await synchronizeUserData(uid); if (!user) { return; diff --git a/packages/web-ui-registration/src/LoginServicesButton.tsx b/packages/web-ui-registration/src/LoginServicesButton.tsx index 7eb22ad5dbfc6..0500a78d68f7e 100644 --- a/packages/web-ui-registration/src/LoginServicesButton.tsx +++ b/packages/web-ui-registration/src/LoginServicesButton.tsx @@ -1,4 +1,5 @@ import { Button } from '@rocket.chat/fuselage'; +import { useLocalStorage } from '@rocket.chat/fuselage-hooks'; import type { Keys as IconName } from '@rocket.chat/icons'; import type { LoginService } from '@rocket.chat/ui-contexts'; import { useLoginWithService } from '@rocket.chat/ui-contexts'; @@ -27,14 +28,21 @@ const LoginServicesButton = ({ const { t } = useTranslation(); const handler = useLoginWithService({ service, buttonLabelText, ...props }); + const [useLegacyOAuth] = useLocalStorage('useLegacyOAuth', false); + const handleOnClick = useCallback(() => { + if (!useLegacyOAuth) { + window.location.href = `/oauth/${service}`; + return; + } + handler().catch((e: { error?: LoginErrors; reason?: string }) => { if (!e.error || typeof e.error !== 'string') { return; } setError?.([e.error, e.reason]); }); - }, [handler, setError]); + }, [handler, setError, useLegacyOAuth, service]); return (