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 /Juick/Model/User.m | |
parent | da64667f6ef19bfeedb8b4b40d875fcd10d4ef6c (diff) |
PDKeychainBindingsController -> SAMKeychain
Diffstat (limited to 'Juick/Model/User.m')
-rw-r--r-- | Juick/Model/User.m | 7 |
1 files changed, 5 insertions, 2 deletions
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) { |