From 0dc0f50868789faf0df666eb356db0077fb758ef Mon Sep 17 00:00:00 2001 From: DenBond7 Date: Tue, 25 Aug 2020 16:05:12 +0300 Subject: [PATCH] Fixed a bug with the token expiration.| #716 --- .../flowcrypt/email/accounts/FlowcryptAccountAuthenticator.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/accounts/FlowcryptAccountAuthenticator.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/accounts/FlowcryptAccountAuthenticator.kt index 4dff4094bf..3d7b585559 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/accounts/FlowcryptAccountAuthenticator.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/accounts/FlowcryptAccountAuthenticator.kt @@ -57,8 +57,9 @@ class FlowcryptAccountAuthenticator(val context: Context) : AbstractAccountAuthe val expireAtInMillis = accountManager.getUserData(account, KEY_EXPIRES_AT)?.toLongOrNull() ?: 0 var authToken = accountManager.peekAuthToken(account, authTokenType) + val isTokenExpired = System.currentTimeMillis() - expireAtInMillis > 0 - if (authToken.isNullOrEmpty()) { + if (authToken.isNullOrEmpty() || isTokenExpired) { val encryptedRefreshToken = accountManager.getUserData(account, KEY_REFRESH_TOKEN) if (encryptedRefreshToken.isNullOrEmpty()) { return Bundle().apply {