File tree Expand file tree Collapse file tree
packages/authentication-client/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -61,14 +61,18 @@ export class AuthenticationClient {
6161 handleSocket ( socket : any ) {
6262 // Connection events happen on every reconnect
6363 const connected = this . app . io ? 'connect' : 'open' ;
64+ const disconnected = this . app . io ? 'disconnect' : 'disconnection' ;
6465
65- socket . on ( connected , ( ) => {
66+ socket . on ( disconnected , ( ) => {
67+ const authPromise = new Promise ( resolve =>
68+ socket . once ( connected , ( ) => resolve ( ) )
69+ )
6670 // Only reconnect when `reAuthenticate()` or `authenticate()`
6771 // has been called explicitly first
68- if ( this . authenticated ) {
69- // Force reauthentication with the server
70- this . reAuthenticate ( true ) ;
71- }
72+ // Force reauthentication with the server
73+ . then ( ( ) => this . authenticated ? this . reAuthenticate ( true ) : null ) ;
74+
75+ this . app . set ( 'authentication' , authPromise ) ;
7276 } ) ;
7377 }
7478
You can’t perform that action at this time.
0 commit comments