summaryrefslogtreecommitdiff
path: root/Juick/ViewControllers/LoginViewController.m
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2019-10-01 17:29:46 +0300
committerGravatar Vitaly Takmazov2019-10-01 22:14:59 +0300
commitdbab6ab54c40a016f75e75a4143576c3fa41c3e0 (patch)
tree6fd5e68ec76c249fcaa07219c53ccab2f4c98fd5 /Juick/ViewControllers/LoginViewController.m
parentaeb513ed5c165e355c9c378efde7445f597d0380 (diff)
Drop AFNetworking and SSKeychain
Diffstat (limited to 'Juick/ViewControllers/LoginViewController.m')
-rw-r--r--Juick/ViewControllers/LoginViewController.m16
1 files changed, 3 insertions, 13 deletions
diff --git a/Juick/ViewControllers/LoginViewController.m b/Juick/ViewControllers/LoginViewController.m
index 898e59c..f9b17a3 100644
--- a/Juick/ViewControllers/LoginViewController.m
+++ b/Juick/ViewControllers/LoginViewController.m
@@ -29,8 +29,8 @@ NSString * const UserSignedInNotificationName = @"UserSignedIn";
target:self action:@selector(cancelSignIn)];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave
target:self action:@selector(doneSignIn)];
- self.usernameField.text = [SAMKeychain passwordForService:[[NSBundle mainBundle] bundleIdentifier] account:@"com.juick.username"];
- self.passwordField.text = [SAMKeychain passwordForService:[[NSBundle mainBundle] bundleIdentifier] account:@"com.juick.password"];;
+ self.usernameField.text = [APIClient sharedClient].credential.user;
+ self.passwordField.text = [APIClient sharedClient].credential.password;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil];
}
@@ -57,6 +57,7 @@ NSString * const UserSignedInNotificationName = @"UserSignedIn";
}
- (void) doneSignIn {
+ [[APIClient sharedClient] setCredential:[NSURLCredential credentialWithUser:self.usernameField.text password:self.passwordField.text persistence:NSURLCredentialPersistenceSynchronizable]];
[[APIClient sharedClient] authenticate:^(User *user, NSError *error) {
if (user) {
[[NSNotificationCenter defaultCenter] postNotificationName:UserSignedInNotificationName object:user];
@@ -73,15 +74,4 @@ NSString * const UserSignedInNotificationName = @"UserSignedIn";
}
}];
}
-- (IBAction)passwordChanged:(id)sender {
- if ([self.passwordField.text isKindOfClass:[NSString class]]) {
- [SAMKeychain setPassword:self.passwordField.text forService:[[NSBundle mainBundle] bundleIdentifier] account:@"com.juick.password"];
- }
-}
-
-- (IBAction)usernameChanged:(id)sender {
- if ([self.usernameField.text isKindOfClass:[NSString class]]) {
- [SAMKeychain setPassword:self.usernameField.text forService:[[NSBundle mainBundle] bundleIdentifier] account:@"com.juick.username"];
- }
-}
@end