Skip to content

Commit

Permalink
fix(logout): Fixed app crash when app token is revoked
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Sein <ivan@nextcloud.com>
  • Loading branch information
Ivansss committed Jan 23, 2025
1 parent c707966 commit 9e7dac5
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions NextcloudTalk/NCSettingsController.m
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,11 @@ - (void)tokenRevokedResponseReceived:(NSNotification *)notification
{
NSString *accountId = [notification.userInfo objectForKey:@"accountId"];
[self logoutAccountWithAccountId:accountId withCompletionBlock:^(NSError *error) {
[[NCUserInterfaceController sharedInstance] presentConversationsList];
[[NCUserInterfaceController sharedInstance] presentLoggedOutInvalidCredentialsAlert];
[[NCConnectionController sharedInstance] checkAppState];
if (!error) {
[[NCUserInterfaceController sharedInstance] presentConversationsList];
[[NCUserInterfaceController sharedInstance] presentLoggedOutInvalidCredentialsAlert];
[[NCConnectionController sharedInstance] checkAppState];
}
}];
}

Expand Down Expand Up @@ -417,6 +419,15 @@ - (void)getUserProfileForAccountId:(NSString *)accountId withCompletionBlock:(Up
- (void)logoutAccountWithAccountId:(NSString *)accountId withCompletionBlock:(LogoutCompletionBlock)block
{
TalkAccount *removingAccount = [[NCDatabaseManager sharedInstance] talkAccountForAccountId:accountId];

if (!removingAccount) {
if (block) {
NSError *error = [NSError errorWithDomain:NSCocoaErrorDomain code:0 userInfo:nil];
block(error);
}
return;
}

if (removingAccount.deviceIdentifier) {
[[NCAPIController sharedInstance] unsubscribeAccount:removingAccount fromNextcloudServerWithCompletionBlock:^(NSError *error) {
if (!error) {
Expand Down

0 comments on commit 9e7dac5

Please sign in to comment.