feat: add force-logout stream listener (#5643)
* feat: add force-logout stream listener * Update app/lib/services/connect.ts
This commit is contained in:
parent
3918b56a82
commit
a1fb966446
|
@ -9,7 +9,7 @@ import protectedFunction from '../methods/helpers/protectedFunction';
|
|||
import database from '../database';
|
||||
import { twoFactor } from './twoFactor';
|
||||
import { store } from '../store/auxStore';
|
||||
import { loginRequest, setLoginServices, setUser } from '../../actions/login';
|
||||
import { loginRequest, logout, setLoginServices, setUser } from '../../actions/login';
|
||||
import sdk from './sdk';
|
||||
import I18n from '../../i18n';
|
||||
import { ICredentials, ILoggedUser, STATUSES } from '../../definitions';
|
||||
|
@ -46,6 +46,7 @@ let usersListener: any;
|
|||
let notifyAllListener: any;
|
||||
let rolesListener: any;
|
||||
let notifyLoggedListener: any;
|
||||
let logoutListener: any;
|
||||
|
||||
function connect({ server, logoutOnError = false }: { server: string; logoutOnError?: boolean }): Promise<void> {
|
||||
return new Promise<void>(resolve => {
|
||||
|
@ -89,6 +90,10 @@ function connect({ server, logoutOnError = false }: { server: string; logoutOnEr
|
|||
notifyLoggedListener.then(stopListener);
|
||||
}
|
||||
|
||||
if (logoutListener) {
|
||||
logoutListener.then(stopListener);
|
||||
}
|
||||
|
||||
unsubscribeRooms();
|
||||
|
||||
EventEmitter.emit('INQUIRY_UNSUBSCRIBE');
|
||||
|
@ -270,6 +275,8 @@ function connect({ server, logoutOnError = false }: { server: string; logoutOnEr
|
|||
})
|
||||
);
|
||||
|
||||
logoutListener = sdk.current.onStreamData('stream-force_logout', () => store.dispatch(logout(true)));
|
||||
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue