refactor(client): move Meteor auth calls behind AuthenticationContext
Merged
GG
6mo ago+151+151+012345678901234567890123456789-110-110-012345678901234567890123456789
Summary
- Add
getLoginToken,loginWithCustomOauth, andwipeLocalAuthmethods toAuthenticationContext, with matchinguseLoginToken,useLoginWithCustomOauth, anduseWipeLocalAuthhooks in@rocket.chat/ui-contexts. - Migrate four consumers off direct
meteor/*imports so that Meteor usage stays confined to the auth/user providers:AuthorizationFormPagereads the stored login token viauseLoginTokeninstead ofAccounts.storageLocation.useStoreCookiesOnLogindoes the same, replacingAccounts._storedLoginToken().useIframeCommandsreplacesMeteor.loginWithToken, the dynamicMeteor[loginWithX]call, andMeteor.logoutwithuseLoginWithToken,useLoginWithCustomOauth, andUserContext.logout. ThelogoutCleanUpside effect is already wired throughUserProvider'sonLogoutlistener, so the inlinesdk.call('logoutCleanUp', ...)is no longer needed.useForceLogoutcollapses theAccounts._unstoreLoginToken()+Meteor.connection.setUserId(null)pair into a singlewipeLocalAuth()call.
Test plan
- OAuth authorize page: open
/oauth/authorize?...while logged in and verify the hiddenaccess_tokenfield is populated and the form submits. - Login flow: confirm
rc_uidandrc_tokencookies are written after a successful login (Chrome DevTools › Application › Cookies). - Iframe integration: enable
Iframe_Integration_receive_enable, then postlogin-with-token,call-custom-oauth-login, andlogoutmessages from a parent frame and confirm each works. - Force logout: trigger an admin-issued force logout and confirm the session flag flips, the router lands on
/login, and the stored login token is cleared from localStorage when the SDK transport is enabled.
Task: ARCH-2131
Summary by CodeRabbit
-
New Features
- Custom OAuth login support with dynamic service handling.
- Ability to read current login token and clear local auth state.
- New hooks to access custom OAuth, login token, and wipe-local-auth actions.
-
Refactor
- Internal auth flows updated to use context-based hooks for more consistent behavior across components.