TF-1974 Check refreshToken is not empty when calling appAuth.token()

(cherry picked from commit 4d06516a91d0c8c9ecf66275abe5f825309c4bba)
This commit is contained in:
dab246
2023-07-04 08:43:22 +07:00
committed by Dat Vu
parent a271b6bacf
commit 052b4ae5c5
2 changed files with 5 additions and 1 deletions
@@ -72,7 +72,8 @@ class DownloadAttachmentsInteractor {
}
} catch (exception) {
log('DownloadAttachmentsInteractor::execute(): $exception');
if (exception is DownloadAttachmentHasTokenExpiredException) {
if (exception is DownloadAttachmentHasTokenExpiredException &&
exception.refreshToken.isNotEmpty) {
yield* _retryDownloadAttachments(
accountId,
baseDownloadUrl,
@@ -79,6 +79,7 @@ class AuthorizationInterceptors extends InterceptorsWrapper {
log('AuthorizationInterceptors::onError(): $err');
if (_isTokenExpired() &&
err.response?.statusCode == 401 &&
_isRefreshTokenNotEmpty() &&
_isAuthenticationOidcValid()) {
try {
final newToken = await _authenticationClient.refreshingTokensOIDC(
@@ -139,6 +140,8 @@ class AuthorizationInterceptors extends InterceptorsWrapper {
return false;
}
bool _isRefreshTokenNotEmpty() => _token != null && _token!.refreshToken.isNotEmpty;
String _getAuthorizationAsBasicHeader(String? authorization) => 'Basic $authorization';
String _getTokenAsBearerHeader(String token) => 'Bearer $token';