diff options
Diffstat (limited to 'Juick')
-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 |
7 files changed, 18 insertions, 16 deletions
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 |