Skip to content

Commit

Permalink
Only wipe local data if logging back in w/ a different username
Browse files Browse the repository at this point in the history
  • Loading branch information
EricSiegNW committed Jun 24, 2016
1 parent 6a420af commit 08ecc3c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
2 changes: 2 additions & 0 deletions APCAppCore/APCAppCore/Startup/APCAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,6 @@ extern NSString *const kNewsFeedStoryBoardKey;
*/
- (void) resetAppAndProceedToSignIn;

- (void) clearPreviousUserData;

@end
16 changes: 10 additions & 6 deletions APCAppCore/APCAppCore/Startup/APCAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -1246,17 +1246,21 @@ - (void) resetAppAndProceedToSignIn
UIViewController * vc = [[UIViewController alloc] init];
vc.view.backgroundColor = [UIColor whiteColor];
appDelegate.window.rootViewController = vc;

// Clear all user info, in case they log in or sign up as a different user afterwards
[appDelegate clearNSUserDefaults];
[APCKeychainStore resetKeyChain];
[appDelegate.dataSubstrate resetCoreData];


// This is all that is needed to force the re-registration of the PIN
APCUser* user = [((id<APCOnboardingManagerProvider>)appDelegate) onboardingManager].user;
user.secondaryInfoSaved = NO;

[self logOutAndGoToSignIn];
}

- (void) clearPreviousUserData
{
// Clear all user info, in case they log in or sign up as a different user afterwards
APCAppDelegate * appDelegate = (APCAppDelegate*) [UIApplication sharedApplication].delegate;
[appDelegate clearNSUserDefaults];
[APCKeychainStore resetKeyChain];
[appDelegate.dataSubstrate resetCoreData];
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,14 @@ - (void) signIn

APCUser * user = [self user];

user.email = self.userHandleTextField.text;
if (user.email != nil && ![user.email isEqualToString:self.userHandleTextField.text] ) {
// Trying to log in as a different user, so clear cached data from the previously logged in user
[((APCAppDelegate*)[UIApplication sharedApplication].delegate) clearPreviousUserData];
}

user.email = self.userHandleTextField.text;
user.password = self.passwordTextField.text;

[user signInOnCompletion:^(NSError *error) {
if (error) {
[spinnerController dismissViewControllerAnimated:YES completion:^{
Expand Down

0 comments on commit 08ecc3c

Please sign in to comment.