@@ -20,12 +20,6 @@ import {getCurrentUserAccountID} from './Report';
2020import updateSessionAuthTokens from './Session/updateSessionAuthTokens' ;
2121import updateSessionUser from './Session/updateSessionUser' ;
2222
23- let credentials : Credentials = { } ;
24- Onyx . connect ( {
25- key : ONYXKEYS . CREDENTIALS ,
26- callback : ( value ) => ( credentials = value ?? { } ) ,
27- } ) ;
28-
2923let stashedCredentials : Credentials = { } ;
3024Onyx . connect ( {
3125 key : ONYXKEYS . STASHED_CREDENTIALS ,
@@ -76,6 +70,10 @@ type WithDelegatedAccess = {
7670 delegatedAccess : DelegatedAccess | undefined ;
7771} ;
7872
73+ type WithCredentials = {
74+ credentials : Credentials | undefined ;
75+ } ;
76+
7977type WithEmail = {
8078 email : string ;
8179} ;
@@ -116,7 +114,7 @@ type UpdateDelegateRoleParams = WithEmail & WithRole & WithValidateCode & WithDe
116114type IsConnectedAsDelegateParams = WithDelegatedAccess ;
117115
118116// Connect as delegate
119- type ConnectParams = WithEmail & WithDelegatedAccess & WithOldDotFlag ;
117+ type ConnectParams = WithEmail & WithDelegatedAccess & WithOldDotFlag & WithCredentials ;
120118
121119// Clear pending action for role update
122120type ClearDelegateRolePendingActionParams = WithEmail & WithDelegatedAccess ;
@@ -125,12 +123,12 @@ type ClearDelegateRolePendingActionParams = WithEmail & WithDelegatedAccess;
125123 * Connects the user as a delegate to another account.
126124 * Returns a Promise that resolves to true on success, false on failure, or undefined if not applicable.
127125 */
128- function connect ( { email, delegatedAccess, isFromOldDot = false } : ConnectParams ) {
126+ function connect ( { email, delegatedAccess, credentials , isFromOldDot = false } : ConnectParams ) {
129127 if ( ! delegatedAccess ?. delegators && ! isFromOldDot ) {
130128 return ;
131129 }
132130
133- Onyx . set ( ONYXKEYS . STASHED_CREDENTIALS , credentials ) ;
131+ Onyx . set ( ONYXKEYS . STASHED_CREDENTIALS , credentials ?? { } ) ;
134132 Onyx . set ( ONYXKEYS . STASHED_SESSION , session ) ;
135133
136134 const previousAccountID = getCurrentUserAccountID ( ) ;
0 commit comments