Skip to content

Commit e6005fe

Browse files
authored
Merge pull request #23 from MuShare/fix/invalidToken
Fix invalid token for un-sign-in state
2 parents 04c0db2 + 50099ce commit e6005fe

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

pluto-kotlin-client-sdk/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ apply plugin: 'kotlin-android-extensions'
44
apply plugin: 'maven-publish'
55

66
buildscript {
7-
ext.versionCode = 24
8-
ext.versionName = '0.8.5'
7+
ext.versionCode = 25
8+
ext.versionName = '0.8.6'
99
}
1010

1111
android {

pluto-kotlin-client-sdk/src/main/java/com/mushare/plutosdk/PlutoResponse.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,15 @@ internal fun parseErrorCodeFromErrorBody(errorBody: ResponseBody?, gson: Gson):
5151
}
5252
val response = gson.fromJson(errorBody.string(), PlutoResponse::class.java)
5353
val plutoError = response?.errorCode ?: PlutoError.badRequest
54-
when(plutoError) {
54+
when (plutoError) {
5555
PlutoError.invalidRefreshToken, PlutoError.invalidAccessToken -> {
5656
Pluto.getInstance()?.let {
57-
it.data.clear()
58-
it.state.value = Pluto.State.invalidRefreshToken
57+
// Skip clearing data if refreshToken is null
58+
// If refreshToken is null, it represents the not sign in state.
59+
if (it.state != Pluto.State.invalidRefreshToken && it.data.refreshToken != null) {
60+
it.data.clear()
61+
it.state.value = Pluto.State.invalidRefreshToken
62+
}
5963
}
6064
}
6165
}

0 commit comments

Comments
 (0)