Skip to content

Commit f0481d5

Browse files
authored
Merge pull request ResearchKit#135 from EricSiegNW/feature/FPHS-694
FPHS 694
2 parents 6a420af + 08ecc3c commit f0481d5

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

APCAppCore/APCAppCore/Startup/APCAppDelegate.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,6 @@ extern NSString *const kNewsFeedStoryBoardKey;
152152
*/
153153
- (void) resetAppAndProceedToSignIn;
154154

155+
- (void) clearPreviousUserData;
156+
155157
@end

APCAppCore/APCAppCore/Startup/APCAppDelegate.m

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,17 +1246,21 @@ - (void) resetAppAndProceedToSignIn
12461246
UIViewController * vc = [[UIViewController alloc] init];
12471247
vc.view.backgroundColor = [UIColor whiteColor];
12481248
appDelegate.window.rootViewController = vc;
1249-
1250-
// Clear all user info, in case they log in or sign up as a different user afterwards
1251-
[appDelegate clearNSUserDefaults];
1252-
[APCKeychainStore resetKeyChain];
1253-
[appDelegate.dataSubstrate resetCoreData];
1254-
1249+
12551250
// This is all that is needed to force the re-registration of the PIN
12561251
APCUser* user = [((id<APCOnboardingManagerProvider>)appDelegate) onboardingManager].user;
12571252
user.secondaryInfoSaved = NO;
12581253

12591254
[self logOutAndGoToSignIn];
12601255
}
12611256

1257+
- (void) clearPreviousUserData
1258+
{
1259+
// Clear all user info, in case they log in or sign up as a different user afterwards
1260+
APCAppDelegate * appDelegate = (APCAppDelegate*) [UIApplication sharedApplication].delegate;
1261+
[appDelegate clearNSUserDefaults];
1262+
[APCKeychainStore resetKeyChain];
1263+
[appDelegate.dataSubstrate resetCoreData];
1264+
}
1265+
12621266
@end

APCAppCore/APCAppCore/UI/Onboarding/SignIn/APCSignInViewController.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,14 @@ - (void) signIn
177177

178178
APCUser * user = [self user];
179179

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

185+
user.email = self.userHandleTextField.text;
182186
user.password = self.passwordTextField.text;
187+
183188
[user signInOnCompletion:^(NSError *error) {
184189
if (error) {
185190
[spinnerController dismissViewControllerAnimated:YES completion:^{

0 commit comments

Comments
 (0)