2
0

Log out active user and key when user is changed or deleted or unset.

This commit is contained in:
Maarten Billemont
2020-04-04 16:30:14 -04:00
parent 975743adec
commit fa0c80d6b3
13 changed files with 52 additions and 44 deletions

View File

@@ -49,10 +49,7 @@
PearlAddNotificationObserver( MPSignedOutNotification, nil, [NSOperationQueue mainQueue],
^(MPAnswersViewController *self, NSNotification *note) {
if (![note.userInfo[@"animated"] boolValue])
[UIView setAnimationsEnabled:NO];
[[MPOverlaySegue dismissViewController:self] perform];
[UIView setAnimationsEnabled:YES];
} );
}

View File

@@ -51,7 +51,7 @@
} );
PearlAddNotificationObserver( MPSignedOutNotification, nil, [NSOperationQueue mainQueue],
^(MPCombinedViewController *self, NSNotification *note) {
[self setMode:MPCombinedModeUserSelection animated:[note.userInfo[@"animated"] boolValue]];
[self setMode:MPCombinedModeUserSelection];
} );
}
@@ -110,7 +110,7 @@
- (void)setMode:(MPCombinedMode)mode {
[self setMode:mode animated:YES];
[self setMode:mode animated:[UIView areAnimationsEnabled]];
}
- (void)setMode:(MPCombinedMode)mode animated:(BOOL)animated {

View File

@@ -64,10 +64,7 @@
PearlAddNotificationObserver( MPSignedOutNotification, nil, [NSOperationQueue mainQueue],
^(MPMessageViewController *self, NSNotification *note) {
if (![note.userInfo[@"animated"] boolValue])
[UIView setAnimationsEnabled:NO];
[[MPOverlaySegue dismissViewController:self] perform];
[UIView setAnimationsEnabled:YES];
} );
}

View File

@@ -98,7 +98,7 @@
UITableViewCell *cell = [self tableView:tableView cellForRowAtIndexPath:indexPath];
if (cell == self.signOutCell) {
[self dismissPopup];
[[MPiOSAppDelegate get] signOutAnimated:YES];
[[MPiOSAppDelegate get] signOut];
}
if (cell == self.feedbackCell)

View File

@@ -363,7 +363,7 @@ typedef NS_OPTIONS( NSUInteger, MPPasswordsTips ) {
[MPiOSAppDelegate managedObjectContextForMainThreadPerformBlock:^(NSManagedObjectContext *mainContext) {
// TODO: either move this into the app delegate or remove the duplicate signOutAnimated: call from the app delegate.
if (![[MPiOSAppDelegate get] activeUserInContext:mainContext])
[[MPiOSAppDelegate get] signOutAnimated:YES];
[[MPiOSAppDelegate get] signOut];
}];
}];
}

View File

@@ -776,7 +776,7 @@ referenceSizeForFooterInSection:(NSInteger)section {
self.masterPasswordChoice = nil;
if (activeUserState != MPActiveUserStateMinimized && (!self.active || [MPiOSAppDelegate get].activeUserOID)) {
[[MPiOSAppDelegate get] signOutAnimated:YES];
[[MPiOSAppDelegate get] signOut];
return;
}

View File

@@ -332,16 +332,16 @@ void mpw_log_sink_pearl(const MPLogEvent *record) {
} );
} );
} result:^(NSError *error) {
[activityOverlay cancelOverlayAnimated:YES];
PearlMainQueue( ^{
[activityOverlay cancelOverlayAnimated:YES];
if (error && !(error.domain == NSCocoaErrorDomain && error.code == NSUserCancelledError)) {
PearlMainQueue( ^{
if (error && !(error.domain == NSCocoaErrorDomain && error.code == NSUserCancelledError)) {
UIAlertController *controller = [UIAlertController alertControllerWithTitle:@"Error" message:[error localizedDescription]
preferredStyle:UIAlertControllerStyleAlert];
[controller addAction:[UIAlertAction actionWithTitle:@"Continue" style:UIAlertActionStyleCancel handler:nil]];
[self.navigationController presentViewController:controller animated:YES completion:nil];
} );
}
}
} );
}];
}
@@ -392,8 +392,11 @@ void mpw_log_sink_pearl(const MPLogEvent *record) {
- (void)applicationDidEnterBackground:(UIApplication *)application {
inf( @"Did background" );
if (![[MPiOSConfig get].rememberLogin boolValue])
[self signOutAnimated:NO];
if (![[MPiOSConfig get].rememberLogin boolValue]) {
[UIView setAnimationsEnabled:NO];
[self signOut];
[UIView setAnimationsEnabled:YES];
}
[self.hangDetector stop];
@@ -661,7 +664,7 @@ void mpw_log_sink_pearl(const MPLogEvent *record) {
[moc saveToStore];
}];
[self signOutAnimated:YES];
[self signOut];
if (didReset)
didReset();
}]];