Skip to content

Commit

Permalink
Remove keychain internet credentials on logout
Browse files Browse the repository at this point in the history
  • Loading branch information
diegolmello committed Aug 12, 2024
1 parent a37d0b4 commit 56f56db
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 4 additions & 2 deletions app/lib/methods/logout.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as FileSystem from 'expo-file-system';
import { Rocketchat as RocketchatClient } from '@rocket.chat/sdk';
import Model from '@nozbe/watermelondb/Model';
import * as Keychain from 'react-native-keychain';

import { getDeviceToken } from '../notifications';
import { extractHostname, isSsl } from './helpers';
Expand All @@ -15,7 +16,7 @@ import { Services } from '../services';
import { roomsSubscription } from './subscriptions/rooms';
import { _activeUsersSubTimeout } from '.';

function removeServerKeys({ server, userId }: { server: string; userId?: string | null }) {
async function removeServerKeys({ server, userId }: { server: string; userId?: string | null }) {
UserPreferences.removeItem(`${TOKEN_KEY}-${server}`);
if (userId) {
UserPreferences.removeItem(`${TOKEN_KEY}-${userId}`);
Expand All @@ -24,6 +25,7 @@ function removeServerKeys({ server, userId }: { server: string; userId?: string
UserPreferences.removeItem(`${server}-${E2E_PUBLIC_KEY}`);
UserPreferences.removeItem(`${server}-${E2E_PRIVATE_KEY}`);
UserPreferences.removeItem(`${server}-${E2E_RANDOM_PASSWORD_KEY}`);
await Keychain.resetInternetCredentials(server);
}

async function removeSharedCredentials({ server }: { server: string }) {
Expand Down Expand Up @@ -56,7 +58,7 @@ export async function removeServerData({ server }: { server: string }): Promise<

await serversDB.write(() => serversDB.batch(...batch));
await removeSharedCredentials({ server });
removeServerKeys({ server, userId });
await removeServerKeys({ server, userId });
} catch (e) {
log(e);
}
Expand Down
1 change: 0 additions & 1 deletion ios/Shared/RocketChat/Storage.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Foundation
import Security
import os

struct Credentials {
let userId: String
Expand Down

0 comments on commit 56f56db

Please sign in to comment.