Skip to content

Commit 0cec488

Browse files
leigaolWill-ShaoHuaandrewyuq
authored
fix(codewhisperer): revise condition for refresh token expiration in CW node (#3780)
* change isUnauthed condition * update condition for checkActiveCodeWhispererConnectionType * detekt fix --------- Co-authored-by: Will Lo <[email protected]> Co-authored-by: yuxqiang <[email protected]> Co-authored-by: andrewyuq <[email protected]>
1 parent 229ee11 commit 0cec488

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

jetbrains-core/src/software/aws/toolkits/jetbrains/core/credentials/ToolkitAuthManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ fun AwsBearerTokenConnection.lazyIsUnauthedBearerConnection(): Boolean {
207207
}
208208

209209
// or state is not authorized
210-
return provider.state() != BearerTokenAuthState.AUTHORIZED
210+
return provider.state() == BearerTokenAuthState.NOT_AUTHENTICATED
211211
}
212212

213213
// not a bearer token provider

jetbrains-core/src/software/aws/toolkits/jetbrains/services/codewhisperer/explorer/CodeWhispererExplorerActionManager.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import software.aws.toolkits.jetbrains.core.explorer.refreshDevToolTree
2020
import software.aws.toolkits.jetbrains.services.codewhisperer.credentials.CodeWhispererLoginType
2121
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererConstants
2222
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererUtil.getConnectionStartUrl
23-
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererUtil.isAccessTokenExpired
2423
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererUtil.isRefreshTokenExpired
2524
import software.aws.toolkits.telemetry.AwsTelemetry
2625
import java.time.LocalDateTime
@@ -120,7 +119,7 @@ class CodeWhispererExplorerActionManager : PersistentStateComponent<CodeWhispere
120119

121120
fun checkActiveCodeWhispererConnectionType(project: Project) = when {
122121
actionState.token != null -> CodeWhispererLoginType.Accountless
123-
isAccessTokenExpired(project) || isRefreshTokenExpired(project) -> CodeWhispererLoginType.Expired
122+
isRefreshTokenExpired(project) -> CodeWhispererLoginType.Expired
124123
else -> {
125124
val conn = ToolkitConnectionManager.getInstance(project).activeConnectionForFeature(CodeWhispererConnection.getInstance())
126125
if (conn != null) {

0 commit comments

Comments
 (0)