Skip to content

Commit 51e5ada

Browse files
authored
Fix logout not clearing token if current user had no device registered (#3838)
* Fix logout not clearing current user token if does not have a device registered * Update CHANGELOG.md
1 parent eda55a7 commit 51e5ada

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
77
### ✅ Added
88
- Add support for deleting messages only for the current user [#3836](https://github.com/GetStream/stream-chat-swift/pull/3836)
99
- Add `ChatMessageController.deleteMessageForMe()`
10-
- Add `ChatMessage.deletedForMe` 
10+
- Add `ChatMessage.deletedForMe`
11+
### 🐞 Fixed
12+
- Fix logout not clearing token when current user had no device registered [#3838](https://github.com/GetStream/stream-chat-swift/pull/3838)
1113

1214
# [4.90.0](https://github.com/GetStream/stream-chat-swift/releases/tag/4.90.0)
1315
_October 07, 2025_

Sources/StreamChat/ChatClient.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -515,14 +515,13 @@ public class ChatClient {
515515
}
516516
self?.authenticationRepository.logOutUser()
517517
}
518+
} else {
519+
authenticationRepository.logOutUser()
518520
}
519521

522+
// Clear current user id instantly even if pending removing device.
520523
authenticationRepository.clearCurrentUserId()
521524

522-
if removeDevice == false {
523-
authenticationRepository.logOutUser()
524-
}
525-
526525
// Stop tracking active components
527526
syncRepository.removeAllTracked()
528527

Tests/StreamChatTests/ChatClient_Tests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ final class ChatClient_Tests: XCTestCase {
340340
XCTAssertEqual(testEnv.apiClient?.request_endpoint?.method, .delete)
341341
}
342342

343-
func test_logout_whenNoCurrentDevice_doesNotRemoveDevice() throws {
343+
func test_logout_whenNoCurrentDevice_doesNotRemoveDevice_shouldClearToken() throws {
344344
// GIVEN
345345
let client = ChatClient(
346346
config: inMemoryStorageConfig,
@@ -363,6 +363,7 @@ final class ChatClient_Tests: XCTestCase {
363363

364364
// THEN
365365
XCTAssertCall(ConnectionRepository_Mock.Signature.disconnect, on: testEnv.connectionRepository!)
366+
XCTAssertCall(AuthenticationRepository_Mock.Signature.logOut, on: testEnv.authenticationRepository!)
366367
XCTAssertNil(testEnv.apiClient?.request_endpoint?.path)
367368
XCTAssertNil(testEnv.apiClient?.request_endpoint?.method)
368369
}

0 commit comments

Comments
 (0)