From 9e7dac5bd951a4a08ea814f377f00559d5f2f073 Mon Sep 17 00:00:00 2001 From: Ivan Sein Date: Thu, 23 Jan 2025 12:29:00 +0100 Subject: [PATCH] fix(logout): Fixed app crash when app token is revoked Signed-off-by: Ivan Sein --- NextcloudTalk/NCSettingsController.m | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/NextcloudTalk/NCSettingsController.m b/NextcloudTalk/NCSettingsController.m index df5145571..b0d23c734 100644 --- a/NextcloudTalk/NCSettingsController.m +++ b/NextcloudTalk/NCSettingsController.m @@ -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]; + } }]; } @@ -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) {