File tree Expand file tree Collapse file tree
projects/auth0-angular/src/lib Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1143,7 +1143,7 @@ describe('AuthService', () => {
11431143 } ) ;
11441144 } ) ;
11451145
1146- it ( 'should add response_type to appState for regular login' , ( done ) => {
1146+ it ( 'should preserve appState as-is for regular login' , ( done ) => {
11471147 const appState = {
11481148 myValue : 'State to Preserve' ,
11491149 } ;
@@ -1158,10 +1158,7 @@ describe('AuthService', () => {
11581158 const localService = createService ( ) ;
11591159 localService . handleRedirectCallback ( ) . subscribe ( ( ) => {
11601160 localService . appState$ . subscribe ( ( receivedState ) => {
1161- expect ( receivedState ) . toEqual ( {
1162- ...appState ,
1163- response_type : ResponseType . Code ,
1164- } ) ;
1161+ expect ( receivedState ) . toEqual ( appState ) ;
11651162 done ( ) ;
11661163 } ) ;
11671164 } ) ;
Original file line number Diff line number Diff line change @@ -391,18 +391,16 @@ export class AuthService<TAppState extends AppState = AppState>
391391 if ( ! isLoading ) {
392392 this . authState . refresh ( ) ;
393393 }
394- const { appState = { } as TAppState , response_type, ...rest } = result ;
394+ const { appState, response_type, ...rest } = result ;
395395 const target = appState ?. target ?? '/' ;
396396
397- // Add response_type to appState
398- appState . response_type = response_type ;
399-
400- // If this is a connect account flow, add the connected account data to appState
401397 if ( response_type === ResponseType . ConnectCode ) {
402- appState . connectedAccount = rest as ConnectedAccount ;
403- }
404-
405- if ( appState ) {
398+ this . appStateSubject$ . next ( {
399+ ...( appState ?? { } ) ,
400+ response_type,
401+ connectedAccount : rest as ConnectedAccount ,
402+ } as TAppState ) ;
403+ } else if ( appState ) {
406404 this . appStateSubject$ . next ( appState ) ;
407405 }
408406
You can’t perform that action at this time.
0 commit comments