Skip to content

Commit 6050a4b

Browse files
committed
Handle pre-HYDRATE logout edge case and redact JWT from logs
LogoutHelper: add explicit null branch for unknown IV state (pre-HYDRATE). Disables push subscription and suppresses backend op (like IV=ON) while also enqueuing a LoginUserOperation so the anonymous user is created on the backend if IV turns out to be OFF. If IV=ON, removeOperationsWithoutExternalId() purges the anonymous op at HYDRATE. Known IV=ON and IV=OFF paths are unchanged. HttpClient: filter Authorization header from requestProperties before passing to logHTTPSent() so the full Bearer token is not written to debug logs. OneSignalImp: redact token in updateUserJwt/updateUserJwtSuspend debug logs. Made-with: Cursor
1 parent ff1a6b2 commit 6050a4b

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

OneSignalSDK/onesignal/core/src/main/java/com/onesignal/core/internal/http/impl/HttpClient.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ internal class HttpClient(
187187
con.setRequestProperty("Authorization", "Bearer ${headers.jwt}")
188188
}
189189

190-
logHTTPSent(con.requestMethod, con.url, jsonBody, con.requestProperties)
190+
logHTTPSent(con.requestMethod, con.url, jsonBody, con.requestProperties.filterKeys { it != "Authorization" })
191191

192192
if (jsonBody != null) {
193193
val strJsonBody = JSONUtils.toUnescapedEUIDString(jsonBody)

OneSignalSDK/onesignal/core/src/main/java/com/onesignal/internal/OneSignalImp.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ internal class OneSignalImp(
425425
externalId: String,
426426
token: String,
427427
) {
428-
Logging.log(LogLevel.DEBUG, "updateUserJwt(externalId: $externalId, token: $token)")
428+
Logging.log(LogLevel.DEBUG, "updateUserJwt(externalId: $externalId, token: <redacted>)")
429429

430430
if (isBackgroundThreadingEnabled) {
431431
waitForInit(operationName = "updateUserJwt")
@@ -444,7 +444,7 @@ internal class OneSignalImp(
444444
externalId: String,
445445
token: String,
446446
) = withContext(runtimeIoDispatcher) {
447-
Logging.log(LogLevel.DEBUG, "updateUserJwtSuspend(externalId: $externalId, token: $token)")
447+
Logging.log(LogLevel.DEBUG, "updateUserJwtSuspend(externalId: $externalId, token: <redacted>)")
448448

449449
suspendUntilInit(operationName = "updateUserJwt")
450450

OneSignalSDK/onesignal/core/src/main/java/com/onesignal/user/internal/LogoutHelper.kt

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,28 @@ class LogoutHelper(
2727
}
2828

2929
userSwitcher.createAndSwitchToNewUser(suppressBackendOperation = true)
30-
} else {
30+
} else if (configModel.useIdentityVerification == false) {
3131
userSwitcher.createAndSwitchToNewUser()
3232

33+
operationRepo.enqueue(
34+
LoginUserOperation(
35+
configModel.appId,
36+
identityModelStore.model.onesignalId,
37+
null,
38+
),
39+
)
40+
} else {
41+
// IV state unknown (pre-HYDRATE). Take the safe path: disable push
42+
// and suppress backend op (like IV=ON), but also enqueue a LoginUserOperation
43+
// so the anonymous user is created on the backend if IV turns out to be OFF.
44+
// If IV=ON, removeOperationsWithoutExternalId() will purge the anonymous op.
45+
configModel.pushSubscriptionId?.let { pushSubId ->
46+
subscriptionModelStore.get(pushSubId)
47+
?.let { it.isDisabledInternally = true }
48+
}
49+
50+
userSwitcher.createAndSwitchToNewUser(suppressBackendOperation = true)
51+
3352
operationRepo.enqueue(
3453
LoginUserOperation(
3554
configModel.appId,

0 commit comments

Comments
 (0)