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

@@ -115,17 +115,9 @@
}
}
- (void)signOutAnimated:(BOOL)animated {
if (self.key)
self.key = nil;
if ([[MPConfig get].sendInfo boolValue]) {
[Countly.sharedInstance userLoggedOut];
}
- (void)signOut {
self.activeUser = nil;
[[NSNotificationCenter defaultCenter] postNotificationName:MPSignedOutNotification object:self userInfo:@{ @"animated": @(animated) }];
}
- (BOOL)signInAsUser:(MPUserEntity *)user saveInContext:(NSManagedObjectContext *)moc usingMasterPassword:(NSString *)password {
@@ -191,7 +183,10 @@
return NO;
}
inf( @"Logged in user: %@", user.userID );
user.lastUsed = [NSDate date];
self.activeUser = user;
if (![self.key isEqualToKey:tryKey]) {
// Upgrade the user's keyID if not at the default version yet.
@@ -222,8 +217,6 @@
err( @"While setting username: %@", exception );
}
user.lastUsed = [NSDate date];
self.activeUser = user;
[moc saveToStore];
// Perform a data sanity check now that we're logged in as the user to allow fixes that require the user's key.