From c22688421066a358b1980f4399f421000febdaac Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 25 Dec 2018 10:37:21 +0300 Subject: PDKeychainBindingsController -> SAMKeychain --- Juick/Model/User.m | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'Juick/Model') 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) { -- cgit v1.2.3