From fa1bf7a6c04cea5df8b68f49bbf69cd1c9a4d235 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 15 May 2020 00:30:28 +0300 Subject: Cleanup unused synchronized credentials --- Juick/AppDelegate.m | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'Juick') diff --git a/Juick/AppDelegate.m b/Juick/AppDelegate.m index 47c18ef..441240a 100644 --- a/Juick/AppDelegate.m +++ b/Juick/AppDelegate.m @@ -26,6 +26,20 @@ NSString * const UserUpdatedNotificationName = @"UserUpdated"; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + // cleanup synchronized credentials which are not used anymore + NSDictionary *dict = [[NSURLCredentialStorage sharedCredentialStorage] allCredentials]; + NSDictionary *dictCopy = [dict copy]; + for(NSURLProtectionSpace *key in [dictCopy keyEnumerator]) + { + if ([key.host isEqual:@"api.juick.com"]) { + NSDictionary *value = [dict objectForKey:key]; + NSArray *creds = [value allValues]; + for (NSURLCredential *cred in creds) { + [[NSURLCredentialStorage sharedCredentialStorage] removeCredential:cred forProtectionSpace:key options:@{ + NSURLCredentialStorageRemoveSynchronizableCredentials:@YES}]; + } + } + } self.api = [API new]; self.sharedDateFormatter = [NSDateFormatter new]; self.sharedDateFormatter.dateFormat = @"yyyy-MM-dd HH:mm:ss"; -- cgit v1.2.3