fix: logout being `undefined`

This commit is contained in:
Gerzon Z 2022-03-08 11:41:00 -04:00
parent 6015349ee1
commit d6ce877a0d
1 changed files with 4 additions and 3 deletions

View File

@ -12,6 +12,7 @@ import log from '../../utils/log';
import { E2E_PRIVATE_KEY, E2E_PUBLIC_KEY, E2E_RANDOM_PASSWORD_KEY } from '../encryption/constants'; import { E2E_PRIVATE_KEY, E2E_PUBLIC_KEY, E2E_RANDOM_PASSWORD_KEY } from '../encryption/constants';
import UserPreferences from '../userPreferences'; import UserPreferences from '../userPreferences';
import { ICertificate, IRocketChat } from '../../definitions'; import { ICertificate, IRocketChat } from '../../definitions';
import sdk from '../rocketchat/services/sdk';
async function removeServerKeys({ server, userId }: { server: string; userId?: string | null }) { async function removeServerKeys({ server, userId }: { server: string; userId?: string | null }) {
await UserPreferences.removeItem(`${RocketChat.TOKEN_KEY}-${server}`); await UserPreferences.removeItem(`${RocketChat.TOKEN_KEY}-${server}`);
@ -116,13 +117,13 @@ export default async function logout(this: IRocketChat, { server }: { server: st
try { try {
// RC 0.60.0 // RC 0.60.0
await this.sdk.logout(); await sdk.current.logout();
} catch (e) { } catch (e) {
log(e); log(e);
} }
if (this.sdk) { if (sdk.current) {
this.sdk = null; sdk.disconnect();
} }
await removeServerData({ server }); await removeServerData({ server });