From dbab6ab54c40a016f75e75a4143576c3fa41c3e0 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 1 Oct 2019 17:29:46 +0300 Subject: Drop AFNetworking and SSKeychain --- Juick/ViewControllers/LoginViewController.m | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'Juick/ViewControllers/LoginViewController.m') 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 -- cgit v1.2.3