Fix/losing email after reopening - #228
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR aims to prevent the premium user email from being lost after app restart/reopen by persisting the email alongside the premium token in secure storage and restoring it when the auth provider rebuilds.
Changes:
- Persist
premium_emailto secure storage on login and delete it on logout. - Restore the persisted email in
AuthNotifier.build()when initializing auth state. - Add the
premiumEmailKeystorage constant and pass the stored email into the premium trouble dialog (currently with a compile-time issue).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/modules/settings/providers/auth_provider.dart | Reads/writes/deletes the premium email in secure storage and restores it on provider build. |
| lib/modules/settings/presentation/widgets/settings_premium_widget.dart | Uses the auth provider email when opening the premium trouble dialog (currently references a non-existent field). |
| lib/core/data/local/secure_storage/secure_storage_const.dart | Adds the premiumEmailKey constant used for secure storage persistence. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
JuliusCaesarCrypto
force-pushed
the
fix/losing-email-after-reopening
branch
from
July 10, 2026 10:59
a677d8b to
51c8593
Compare
Comment on lines
21
to
25
| final token = await storage.read(premiumTokenKey); | ||
| final email = await storage.read(premiumEmailKey) ?? ''; | ||
|
|
||
| return AuthData(email: '', isLoggedIn: token?.isNotEmpty ?? false); | ||
| return AuthData(email: email, isLoggedIn: token?.isNotEmpty ?? false); | ||
| } |
Comment on lines
21
to
25
| final token = await storage.read(premiumTokenKey); | ||
| final email = await storage.read(premiumEmailKey) ?? ''; | ||
|
|
||
| return AuthData(email: '', isLoggedIn: token?.isNotEmpty ?? false); | ||
| return AuthData(email: email, isLoggedIn: token?.isNotEmpty ?? false); | ||
| } |
Comment on lines
27
to
34
| Future<void> login(String email, String token) async { | ||
| final storage = ref.read(secureStorageProvider); | ||
|
|
||
| await storage.write(premiumTokenKey, token); | ||
| await storage.write(premiumEmailKey, email); | ||
|
|
||
| state = AsyncData(AuthData(email: email, isLoggedIn: true)); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Change Description
Briefly describe what this PR does and why. Keep it short and clear.
Related Platforms
Verification Checklist
Optional (for bigger changes)
Related Links
Closes #ID.