Skip to content

Commit

Permalink
Merge pull request ResearchKit#135 from EricSiegNW/feature/FPHS-694
Browse files Browse the repository at this point in the history
FPHS 694
  • Loading branch information
Erin-Mounts committed Jun 24, 2016
2 parents 6a420af + 08ecc3c commit f0481d5
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
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
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
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 f0481d5

Please sign in to comment.