@@ -493,9 +493,10 @@ export default class Clerk implements ClerkInterface {
493493 }
494494
495495 this . session = session ;
496- this . organization = ( this . session ?. user . organizationMemberships || [ ] )
497- . map ( om => om . organization )
498- . find ( org => org . id === this . session ?. lastActiveOrganizationId ) ;
496+ this . organization =
497+ ( this . session ?. user . organizationMemberships || [ ] )
498+ . map ( om => om . organization )
499+ . find ( org => org . id === this . session ?. lastActiveOrganizationId ) || null ;
499500 this . user = this . session ? this . session . user : null ;
500501
501502 this . #emit( ) ;
@@ -903,19 +904,21 @@ export default class Clerk implements ClerkInterface {
903904 ( this . #options. selectInitialSession
904905 ? this . #options. selectInitialSession ( newClient )
905906 : this . #defaultSession( newClient ) ) || null ;
906- this . organization = ( this . session ?. user . organizationMemberships || [ ] )
907- . map ( om => om . organization )
908- . find ( org => org . id === this . session ?. lastActiveOrganizationId ) ;
907+ this . organization =
908+ ( this . session ?. user . organizationMemberships || [ ] )
909+ . map ( om => om . organization )
910+ . find ( org => org . id === this . session ?. lastActiveOrganizationId ) || null ;
909911 this . user = this . session ? this . session . user : null ;
910912 }
911913 this . client = newClient ;
912914
913915 if ( this . session ) {
914916 const lastId = this . session . id ;
915917 this . session = newClient . activeSessions . find ( x => x . id === lastId ) ;
916- this . organization = ( this . session ?. user . organizationMemberships || [ ] )
917- . map ( om => om . organization )
918- . find ( org => org . id === this . session ?. lastActiveOrganizationId ) ;
918+ this . organization =
919+ ( this . session ?. user . organizationMemberships || [ ] )
920+ . map ( om => om . organization )
921+ . find ( org => org . id === this . session ?. lastActiveOrganizationId ) || null ;
919922 this . user = this . session ? this . session . user : null ;
920923 }
921924
0 commit comments