summaryrefslogtreecommitdiff
path: root/Juick/Model
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-12-25 10:37:21 +0300
committerGravatar Vitaly Takmazov2018-12-25 10:44:07 +0300
commitc22688421066a358b1980f4399f421000febdaac (patch)
treef48ac07d5e95b79e928cba1dc89f55e2517f07ed /Juick/Model
parentda64667f6ef19bfeedb8b4b40d875fcd10d4ef6c (diff)
PDKeychainBindingsController -> SAMKeychain
Diffstat (limited to 'Juick/Model')
-rw-r--r--Juick/Model/User.m7
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) {