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

@@ -21,6 +21,8 @@
#import "MPAppDelegate_Key.h"
#import "NSManagedObjectModel+KCOrderedAccessorFix.h"
#import <Countly/Countly.h>
@interface MPAppDelegate_Shared()
@property(strong, atomic) MPKey *key;
@@ -63,14 +65,26 @@ static MPAppDelegate_Shared *instance;
MPUserEntity *activeUser = [MPUserEntity existingObjectWithID:activeUserOID inContext:context];
if (!activeUser)
[self signOutAnimated:YES];
[self signOut];
return activeUser;
}
- (void)setActiveUser:(MPUserEntity *)activeUser {
self.activeUserOID = activeUser.permanentObjectID;
NSManagedObjectID *activeUserOID = activeUser.permanentObjectID;
if ([self.activeUserOID isEqualTo:activeUserOID])
return;
if (self.key)
self.key = nil;
if ([[MPConfig get].sendInfo boolValue])
[Countly.sharedInstance userLoggedOut];
[[NSNotificationCenter defaultCenter] postNotificationName:MPSignedOutNotification object:self];
self.activeUserOID = activeUserOID;
}
- (void)handleCoordinatorError:(NSError *)error {