fix(auth): clear token from SharedPreferences on logout#538
fix(auth): clear token from SharedPreferences on logout#538may-tas wants to merge 1 commit intoCircuitVerse:masterfrom
Conversation
✅ Deploy Preview for cv-mobile-app-web ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
WalkthroughThe Suggested labels
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip You can generate walkthrough in a markdown collapsible section to save space.Enable the |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
lib/services/local_storage_service.dart (1)
82-84:⚠️ Potential issue | 🟠 Major
currentUsersetter won't remove the key on logout due tojson.encode(null)returning"null"string.When
userToSaveisnull,json.encode(userToSave?.toJson())evaluates tojson.encode(null), which returns the literal string"null"(not actualnull). This non-null string is then saved to SharedPreferences, bypassing the new removal logic.While the getter handles the
'null'string check, the user data isn't actually removed from persistent storage, which contradicts the PR objective of preventing identity leaks.🔒 Proposed fix to ensure key removal when user is null
set currentUser(User? userToSave) { - _saveToDisk(USER, json.encode(userToSave?.toJson())); + _saveToDisk(USER, userToSave == null ? null : json.encode(userToSave.toJson())); }
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 555fff4c-ae1e-462e-af1a-0c0ceb0a97f3
📒 Files selected for processing (1)
lib/services/local_storage_service.dart
Fixes #536
Describe the changes you have made in this PR -
nullcheck inlib/services/local_storage_service.dartat the beginning of_saveToDisk().content is Stringcheck, resulting in tokens never actually being removed fromSharedPreferenceswhen a user logged out.nullcorrectly triggers_preferences!.remove(key)directly.Screenshots of the changes (If any) -
N/A
Summary by CodeRabbit