Log out active user and key when user is changed or deleted or unset.
This commit is contained in:
@@ -295,8 +295,6 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
|
||||
|
||||
- (void)selectUser:(NSMenuItem *)item {
|
||||
|
||||
[self signOutAnimated:NO];
|
||||
|
||||
NSManagedObjectContext *mainContext = [MPMacAppDelegate managedObjectContextForMainThreadIfReady];
|
||||
self.activeUser = [MPUserEntity existingObjectWithID:[item representedObject] inContext:mainContext];
|
||||
}
|
||||
@@ -369,10 +367,12 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
|
||||
|
||||
return masterPassword;
|
||||
} result:^(NSError *error) {
|
||||
[self updateUsers];
|
||||
PearlMainQueue( ^{
|
||||
[self updateUsers];
|
||||
|
||||
if (error && !(error.domain == NSCocoaErrorDomain && error.code == NSUserCancelledError))
|
||||
[[NSAlert alertWithError:error] runModal];
|
||||
if (error && !(error.domain == NSCocoaErrorDomain && error.code == NSUserCancelledError))
|
||||
[[NSAlert alertWithError:error] runModal];
|
||||
} );
|
||||
}];
|
||||
}] resume];
|
||||
}
|
||||
@@ -458,7 +458,7 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
|
||||
|
||||
- (IBAction)lock:(id)sender {
|
||||
|
||||
[self signOutAnimated:YES];
|
||||
[self signOut];
|
||||
}
|
||||
|
||||
- (IBAction)terminate:(id)sender {
|
||||
@@ -642,6 +642,9 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
|
||||
userItem.state = NSOffState;
|
||||
}
|
||||
|
||||
if (!mainActiveUser)
|
||||
[self.sitesWindowController close];
|
||||
|
||||
[self updateMenuItems];
|
||||
}
|
||||
|
||||
|
@@ -51,8 +51,6 @@
|
||||
} );
|
||||
PearlAddNotificationObserver( NSWindowWillCloseNotification, self.window, [NSOperationQueue mainQueue],
|
||||
^(id host, NSNotification *note) {
|
||||
PearlRemoveNotificationObservers();
|
||||
|
||||
NSWindow *sheet = [self.window attachedSheet];
|
||||
if (sheet)
|
||||
[self.window endSheet:sheet];
|
||||
@@ -86,6 +84,10 @@
|
||||
prof_finish( @"ui" );
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
PearlRemoveNotificationObservers();
|
||||
}
|
||||
|
||||
- (void)replaceFonts:(NSView *)view {
|
||||
|
||||
if (view.window.backingScaleFactor == 1)
|
||||
@@ -325,7 +327,7 @@
|
||||
[alert_ beginSheetModalForWindow:self.window completionHandler:nil];
|
||||
|
||||
if ([MPMacAppDelegate get].key)
|
||||
[[MPMacAppDelegate get] signOutAnimated:YES];
|
||||
[[MPMacAppDelegate get] signOut];
|
||||
} );
|
||||
}];
|
||||
}
|
||||
@@ -573,7 +575,6 @@
|
||||
}
|
||||
prof_finish( @"newSites: %@", newSites );
|
||||
|
||||
dbg( @"newSites: %@", newSites );
|
||||
if (![newSites isEqualToArray:self.sites])
|
||||
PearlMainQueue( ^{
|
||||
self.sites = newSites;
|
||||
|
Reference in New Issue
Block a user