Fix ios cache (#7412)

* Fix Keychain cache

* Fix

* Fix import
This commit is contained in:
Daniel Espino García 2023-07-05 20:01:51 +02:00 committed by GitHub
parent 54e7bd81d5
commit 5ab2f86b66
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 23 additions and 0 deletions

View file

@ -221,6 +221,11 @@ public class MattermostManagedModule extends ReactContextBaseJavaModule {
}
}
@ReactMethod
public void invalidateKeychainCache(String serverUrl) {
// Not using cache
}
private static class SaveDataTask extends GuardedResultAsyncTask<Object> {
private final WeakReference<Context> weakContext;
private final String fromFile;

View file

@ -22,6 +22,7 @@ import {getThemeFromState} from '@screens/navigation';
import EphemeralStore from '@store/ephemeral_store';
import {deleteFileCache, deleteFileCacheByDir} from '@utils/file';
import {isMainActivity} from '@utils/helpers';
import {invalidateKeychainCache} from '@utils/mattermost_managed';
import {addNewServer} from '@utils/server';
import type {LaunchType} from '@typings/launch';
@ -115,6 +116,7 @@ class SessionManager {
private terminateSession = async (serverUrl: string, removeServer: boolean) => {
cancelSessionNotification(serverUrl);
await removeServerCredentials(serverUrl);
invalidateKeychainCache(serverUrl);
PushNotifications.removeServerNotifications(serverUrl);
NetworkManager.invalidateClient(serverUrl);

View file

@ -64,3 +64,7 @@ export const deleteEntititesFile = (callback?: (success: boolean) => void) => {
callback(true);
}
};
export const invalidateKeychainCache = (serverUrl: string) => {
MattermostManaged.invalidateKeychainCache(serverUrl);
};

View file

@ -100,6 +100,10 @@ public class Keychain: NSObject {
return nil
}
public func invalidateToken(for serverUrl: String) {
tokenCache.removeValue(forKey: serverUrl)
}
private func buildIdentityQuery(for host: String) throws -> [CFString: Any] {
guard let hostData = host.data(using: .utf8) else {

View file

@ -42,4 +42,8 @@ import Gekidou
return nil
}
@objc func invalidateToken(for url: String) {
Keychain.default.invalidateToken(for: url)
}
}

View file

@ -153,6 +153,10 @@ RCT_EXPORT_METHOD(removeListeners:(double)count) {
// Keep: Required for RN built in Event Emitter Calls.
}
RCT_EXPORT_METHOD(invalidateKeychainCache:(NSString *) serverUrl)
{
[[GekidouWrapper default] invalidateTokenFor:serverUrl];
}
RCT_EXPORT_METHOD(createThumbnail:(NSDictionary *)config findEventsWithResolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
{