From c5042e2ce9c823ccfe8db3b92345883f1132fd85 Mon Sep 17 00:00:00 2001 From: khanhduytran0 Date: Sun, 13 Apr 2025 17:25:12 +0700 Subject: [PATCH] Fix[auth]: don't crash if fails to load token from keychain --- Natives/authenticator/MicrosoftAuthenticator.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Natives/authenticator/MicrosoftAuthenticator.m b/Natives/authenticator/MicrosoftAuthenticator.m index 5ab25a74..ba15c96c 100644 --- a/Natives/authenticator/MicrosoftAuthenticator.m +++ b/Natives/authenticator/MicrosoftAuthenticator.m @@ -217,9 +217,13 @@ typedef void(^XSTSCallback)(NSString *xsts, NSString *uhs); - (void)refreshTokenWithCallback:(Callback)callback { // Move tokens to keychain if we haven't if (!self.tokenData) { - [self saveChanges]; + showDialog(localize(@"Error", nil), @"Failed to load account tokens from keychain"); + callback(nil, YES); + return; } + [self saveChanges]; + if ([NSDate.date timeIntervalSince1970] > [self.authData[@"expiresAt"] longValue]) { [self acquireAccessToken:self.tokenData[@"refreshToken"] refresh:YES callback:callback]; } else {