diff options
author | Vitaly Takmazov | 2018-12-25 10:37:21 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-12-25 10:44:07 +0300 |
commit | c22688421066a358b1980f4399f421000febdaac (patch) | |
tree | f48ac07d5e95b79e928cba1dc89f55e2517f07ed | |
parent | da64667f6ef19bfeedb8b4b40d875fcd10d4ef6c (diff) |
PDKeychainBindingsController -> SAMKeychain
-rw-r--r-- | Juick.xcodeproj/project.pbxproj | 2 | ||||
-rw-r--r-- | Juick/APIClient.m | 5 | ||||
-rw-r--r-- | Juick/AppDelegate.m | 5 | ||||
-rw-r--r-- | Juick/Model/User.m | 7 | ||||
-rw-r--r-- | Juick/Supporting Files/Juick-Prefix.pch | 2 | ||||
-rw-r--r-- | Juick/ViewControllers/ChatViewController.m | 2 | ||||
-rw-r--r-- | Juick/ViewControllers/LoginViewController.h | 1 | ||||
-rw-r--r-- | Juick/ViewControllers/LoginViewController.m | 12 | ||||
-rw-r--r-- | Podfile | 2 | ||||
-rw-r--r-- | Podfile.lock | 10 |
10 files changed, 26 insertions, 22 deletions
diff --git a/Juick.xcodeproj/project.pbxproj b/Juick.xcodeproj/project.pbxproj index 2ffe164..657b462 100644 --- a/Juick.xcodeproj/project.pbxproj +++ b/Juick.xcodeproj/project.pbxproj @@ -527,6 +527,7 @@ inputPaths = ( "${SRCROOT}/Pods/Target Support Files/Pods-Juick/Pods-Juick-resources.sh", "${PODS_ROOT}/DateTools/DateTools/DateTools/DateTools.bundle", + "${PODS_ROOT}/SAMKeychain/Support/SAMKeychain.bundle", "${PODS_CONFIGURATION_BUILD_DIR}/TagListView-ObjC/TagListView-ObjC.bundle", ); name = "[CP] Copy Pods Resources"; @@ -534,6 +535,7 @@ ); outputPaths = ( "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/DateTools.bundle", + "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/SAMKeychain.bundle", "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/TagListView-ObjC.bundle", ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Juick/APIClient.m b/Juick/APIClient.m index 3c91173..b812057 100644 --- a/Juick/APIClient.m +++ b/Juick/APIClient.m @@ -6,7 +6,6 @@ // Copyright © 2016 com.juick. All rights reserved. // #import "APIClient.h" -#import "PDKeychainBindings.h" #import "Message.h" #import "Chat.h" @@ -32,9 +31,9 @@ self.manager = [[AFHTTPSessionManager alloc] initWithBaseURL:[NSURL URLWithString:baseURLString]]; self.manager.requestSerializer = [AFJSONRequestSerializer new]; [self.manager.requestSerializer setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData]; - NSString *username = [[PDKeychainBindings sharedKeychainBindings] stringForKey:@"com.juick.username"]; + NSString *username = [SAMKeychain passwordForService:[[NSBundle mainBundle] bundleIdentifier] account:@"com.juick.username"]; if (username) { - [self.manager.requestSerializer setAuthorizationHeaderFieldWithUsername:username password:[[PDKeychainBindings sharedKeychainBindings] stringForKey:@"com.juick.password"]]; + [self.manager.requestSerializer setAuthorizationHeaderFieldWithUsername:username password:[SAMKeychain passwordForService:[[NSBundle mainBundle] bundleIdentifier] account:@"com.juick.password"]]; } self.backgroundQueue = [NSOperationQueue new]; self.dateFormatter = [[NSDateFormatter alloc] init]; diff --git a/Juick/AppDelegate.m b/Juick/AppDelegate.m index a07d0e3..c3a2f77 100644 --- a/Juick/AppDelegate.m +++ b/Juick/AppDelegate.m @@ -40,9 +40,8 @@ [self parseNotificationPayload:userInfo]; } else { if ([[NSUserDefaults standardUserDefaults] objectForKey:@"FirstRun"] == nil) { - [[PDKeychainBindings sharedKeychainBindings] setObject:nil forKey:@"com.juick.username"]; - [[PDKeychainBindings sharedKeychainBindings] setObject:nil forKey:@"com.juick.password"]; - [[NSUserDefaults standardUserDefaults] setObject:@"1" forKey:@"FirstRun"]; + [SAMKeychain deletePasswordForService:[[NSBundle mainBundle] bundleIdentifier] account:@"com.juick.username"]; + [SAMKeychain deletePasswordForService:[[NSBundle mainBundle] bundleIdentifier] account:@"com.juick.username"]; } } return YES; diff --git a/Juick/Model/User.m b/Juick/Model/User.m index a2f874c..4043894 100644 --- a/Juick/Model/User.m +++ b/Juick/Model/User.m @@ -20,7 +20,8 @@ } +(BOOL) isAuthenticated { - return [[PDKeychainBindings sharedKeychainBindings] stringForKey:@"com.juick.username"] != nil; + NSString *password = [SAMKeychain passwordForService:[[NSBundle mainBundle] bundleIdentifier] account:@"com.juick.password"]; + return password != nil; } +(void) throwUnableToLogin:(UIViewController *)view { @@ -39,7 +40,9 @@ +(void) checkIsValid:(void (^)(BOOL))callback { AFHTTPSessionManager *manager = [APIClient sharedClient].manager; - [manager.requestSerializer setAuthorizationHeaderFieldWithUsername:[[PDKeychainBindings sharedKeychainBindings] stringForKey:@"com.juick.username"] password:[[PDKeychainBindings sharedKeychainBindings] stringForKey:@"com.juick.password"]]; + NSString *username = [SAMKeychain passwordForService:[[NSBundle mainBundle] bundleIdentifier] account:@"com.juick.username"]; + NSString *password = [SAMKeychain passwordForService:[[NSBundle mainBundle] bundleIdentifier] account:@"com.juick.password"]; + [manager.requestSerializer setAuthorizationHeaderFieldWithUsername:username password:password]; [manager POST:@"post" parameters:nil progress:nil success:nil failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { NSInteger statusCode = ((NSHTTPURLResponse *)task.response).statusCode; if (statusCode == 400) { diff --git a/Juick/Supporting Files/Juick-Prefix.pch b/Juick/Supporting Files/Juick-Prefix.pch index a4b3d0f..b2595f6 100644 --- a/Juick/Supporting Files/Juick-Prefix.pch +++ b/Juick/Supporting Files/Juick-Prefix.pch @@ -17,7 +17,7 @@ #import <MobileCoreServices/MobileCoreServices.h> #import <UserNotifications/UserNotifications.h> - #import <PDKeychainBindingsController/PDKeychainBindingsController.h> + #import <SAMKeychain/SAMKeychain.h> #import "UIImage+Utils.h" #import <AFNetworking/AFNetworking.h> #import <AFNetworking/UIImageView+AFNetworking.h> diff --git a/Juick/ViewControllers/ChatViewController.m b/Juick/ViewControllers/ChatViewController.m index 54614b7..a76cc00 100644 --- a/Juick/ViewControllers/ChatViewController.m +++ b/Juick/ViewControllers/ChatViewController.m @@ -26,7 +26,7 @@ self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; self.tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeInteractive; self.tableView.allowsSelection = NO; - self.me = [[PDKeychainBindings sharedKeychainBindings] stringForKey:@"com.juick.username"]; + self.me = [SAMKeychain passwordForService:[[NSBundle mainBundle] bundleIdentifier] account:@"com.juick.username"]; [self reloadChat]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillChangeFrame:) name:UIKeyboardWillChangeFrameNotification object:nil]; self.refreshControl = [UIRefreshControl new]; diff --git a/Juick/ViewControllers/LoginViewController.h b/Juick/ViewControllers/LoginViewController.h index 18ca4a4..12707f5 100644 --- a/Juick/ViewControllers/LoginViewController.h +++ b/Juick/ViewControllers/LoginViewController.h @@ -7,7 +7,6 @@ // #import <UIKit/UIKit.h> -#import "PDKeychainBindingsController.h" @interface LoginViewController : UIViewController @property (weak, nonatomic) IBOutlet UITextField *usernameField; diff --git a/Juick/ViewControllers/LoginViewController.m b/Juick/ViewControllers/LoginViewController.m index 917d563..c0b1a0d 100644 --- a/Juick/ViewControllers/LoginViewController.m +++ b/Juick/ViewControllers/LoginViewController.m @@ -28,8 +28,8 @@ target:self action:@selector(cancelSignIn)]; self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:@selector(doneSignIn)]; - self.usernameField.text = [[PDKeychainBindings sharedKeychainBindings] stringForKey:@"com.juick.username"]; - self.passwordField.text = [[PDKeychainBindings sharedKeychainBindings] stringForKey:@"com.juick.password"]; + self.usernameField.text = [SAMKeychain passwordForService:[[NSBundle mainBundle] bundleIdentifier] account:@"com.juick.username"]; + self.passwordField.text = [SAMKeychain passwordForService:[[NSBundle mainBundle] bundleIdentifier] account:@"com.juick.password"];; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil]; } @@ -58,7 +58,9 @@ - (void) doneSignIn { [User checkIsValid:^(BOOL success) { if (success) { - [[APIClient sharedClient].manager.requestSerializer setAuthorizationHeaderFieldWithUsername:[[PDKeychainBindings sharedKeychainBindings] stringForKey:@"com.juick.username"] password:[[PDKeychainBindings sharedKeychainBindings] stringForKey:@"com.juick.password"]]; + NSString *username = [SAMKeychain passwordForService:[[NSBundle mainBundle] bundleIdentifier] account:@"com.juick.username"]; + NSString *password = [SAMKeychain passwordForService:[[NSBundle mainBundle] bundleIdentifier] account:@"com.juick.password"]; + [[APIClient sharedClient].manager.requestSerializer setAuthorizationHeaderFieldWithUsername:username password:password]; AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication] delegate]; [app registerForRemoteNotifications]; @@ -77,13 +79,13 @@ } - (IBAction)passwordChanged:(id)sender { if ([self.passwordField.text isKindOfClass:[NSString class]]) { - [[PDKeychainBindings sharedKeychainBindings] setObject:self.passwordField.text forKey:@"com.juick.password"]; + [SAMKeychain setPassword:self.passwordField.text forService:[[NSBundle mainBundle] bundleIdentifier] account:@"com.juick.password"]; } } - (IBAction)usernameChanged:(id)sender { if ([self.usernameField.text isKindOfClass:[NSString class]]) { - [[PDKeychainBindings sharedKeychainBindings] setObject:self.usernameField.text forKey:@"com.juick.username"]; + [SAMKeychain setPassword:self.usernameField.text forService:[[NSBundle mainBundle] bundleIdentifier] account:@"com.juick.username"]; } } @end @@ -3,7 +3,7 @@ platform :ios, "11.1" target "Juick" do pod 'AFNetworking' - pod 'PDKeychainBindingsController' + pod 'SAMKeychain' pod 'DateTools' pod 'TagListView-ObjC' pod 'PHFComposeBarView' diff --git a/Podfile.lock b/Podfile.lock index 05ec9b0..c5e193c 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -15,18 +15,18 @@ PODS: - AFNetworking/UIKit (3.2.1): - AFNetworking/NSURLSession - DateTools (2.0.0) - - PDKeychainBindingsController (0.0.1) - PHFComposeBarView (2.1.0): - PHFDelegateChain (~> 1.0) - PHFDelegateChain (1.0.1) + - SAMKeychain (1.5.3) - TagListView-ObjC (0.1.1) - "UIView+Shimmer (1.0.0)" DEPENDENCIES: - AFNetworking - DateTools - - PDKeychainBindingsController - PHFComposeBarView + - SAMKeychain - TagListView-ObjC - "UIView+Shimmer" @@ -34,21 +34,21 @@ SPEC REPOS: https://github.com/cocoapods/specs.git: - AFNetworking - DateTools - - PDKeychainBindingsController - PHFComposeBarView - PHFDelegateChain + - SAMKeychain - TagListView-ObjC - "UIView+Shimmer" SPEC CHECKSUMS: AFNetworking: b6f891fdfaed196b46c7a83cf209e09697b94057 DateTools: 933ac9c490f21f92127cf690ccd8c397e0126caf - PDKeychainBindingsController: fa8cb3cf99f2ea9240d61066ed0549f34e2cec3c PHFComposeBarView: 6382ab846e2f4d8634273c4a78d074bc5deed07f PHFDelegateChain: 491f9cd8a3fb8761f390ff05f74a0e168d48d285 + SAMKeychain: 483e1c9f32984d50ca961e26818a534283b4cd5c TagListView-ObjC: 432991e24c5177eb4fa7d721de7084f09f39a0b8 "UIView+Shimmer": ed634f95e8f4bda666b28b47bd85a4336a4117d8 -PODFILE CHECKSUM: acb9b85a84c58e82301075a1b96c09b73c238ce5 +PODFILE CHECKSUM: cc35a42b2427e437120b816a942bf19b967d06b8 COCOAPODS: 1.5.3 |