fix(auth): Resolve logout issue caused by JWT token serialization breaking change #3162
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue #, if available:
#3159
Description of changes:
Fix: Resolve logout issue caused by JWT token serialization breaking change
Problem
Commit
047483866231622a362f736350f600072affad86introduced type-safe JWT token classes but inadvertently created a breaking change in the serialized data structure. This caused existing users to be automatically logged out when updating to the new version.Root Cause: The new token classes (
IdToken,AccessToken,RefreshToken) were serialized as nested objects instead of flat strings, causing deserialization failures for existing stored tokens.Impact
"idToken": "eyJhbGc..."could not be deserialized"idToken": {"tokenValue": "eyJhbGc..."}Solution
Added backward-compatible serialization that:
"idToken": "eyJhbGc...")Changes Made
Core Implementation
IdTokenAsStringSerializer,AccessTokenAsStringSerializer,RefreshTokenAsStringSerializerextractTokenValue()helper detects and handles both formatsComprehensive Testing
Backward Compatibility Matrix
"idToken": "eyJhbGc...""idToken": {"tokenValue": "eyJhbGc..."}"idToken": "eyJhbGc..."Files Changed
Tokens.kt: Added backward-compatible serializersTokensTest.kt: Comprehensive serialization compatibility testsTesting
This fix ensures no users experience logout issues while maintaining all the benefits of the type-safe JWT implementation.
How did you test these changes?
(Please add a line here how the changes were tested)
Documentation update required?
General Checklist
fix(storage): message,feat(auth): message,chore(all): message)By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.