feat: display user's real name with time-based greeting in header. #7421
feat: display user's real name with time-based greeting in header. #7421chetanr25 wants to merge 11 commits intoopenfoodfacts:developfrom
Conversation
…a way to extract userDetails and store in provider. Closes openfoodfacts#7372
…72_greet_username
serDetails after app is restarted. UserDetails is stored in DaoSecuredString by se rialization
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #7421 +/- ##
==========================================
- Coverage 9.54% 9.10% -0.45%
==========================================
Files 325 625 +300
Lines 16411 36664 +20253
==========================================
+ Hits 1567 3337 +1770
- Misses 14844 33327 +18483 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
UserDetails is serialized to JSON for storage since we need multiple fields from it (name, preferredLanguage, country, isModerator). This approach is easier to maintain than storing each field separately, and automatically supports any new fields added to UserDetails in the future. Does this seem like the right approach or would you prefer something different? |
…72_greet_username
… into 7372_greet_username
teolemon
left a comment
There was a problem hiding this comment.
- I'm not sure we can assume a name 100% of the time. We should have a fallback, and a path to fixing it if it is not corrrect
- I'm not completely sure about the time of the day thing, since the string might overflow, and it might be a bit overkill
There was a problem hiding this comment.
Pull request overview
Updates the Preferences/Community header to greet the logged-in user by their real name (when available) instead of only showing the userId, by persisting UserDetails from the login flow and adding new localized greeting strings.
Changes:
- Extend the login flow (
LoginResult) to carryUserDetailsand persist them in secure storage. - Add time-of-day greeting strings to l10n and display a greeting + name in the logged-in header.
- Introduce
UserManagementProvider.globalUserDetailsfor retrieving the stored name globally.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/smooth_app/lib/l10n/app_localizations.dart | Generated localization interface updated with new greeting getters. |
| packages/smooth_app/lib/l10n/app_en.arb | Adds English strings for the new greeting keys. |
| packages/smooth_app/lib/generic_lib/widgets/app_bars/logged_in/logged_in_app_bar_header.dart | Displays a time-based greeting and the user’s real name (fallback to userId). |
| packages/smooth_app/lib/data_models/user_management_provider.dart | Saves/restores UserDetails to secure storage and clears them on logout. |
| packages/smooth_app/lib/data_models/login_result.dart | Adds userDetails to LoginResult and populates it from LoginStatus. |
| DaoSecuredString.remove(key: _USER_ID); | ||
| DaoSecuredString.remove(key: _PASSWORD); | ||
| DaoSecuredString.remove(key: _COOKIE); | ||
| DaoSecuredString.remove(key: _USER_DETAILS); | ||
| Logs.e('Credentials query failed, you have been logged out'); |
There was a problem hiding this comment.
In the PlatformException handler, DaoSecuredString.remove is async but not awaited. That can leave stale credentials/user_details in secure storage after a decryption failure. Await these removals (e.g. Future.wait) so the cleanup is guaranteed before continuing.
| Logs.e('Failed to parse UserDetails: $e'); | ||
| DaoSecuredString.remove(key: _USER_DETAILS); | ||
| } |
There was a problem hiding this comment.
When JSON parsing fails, DaoSecuredString.remove(_USER_DETAILS) is async but not awaited. Awaiting the removal ensures corrupted data is actually cleared before the next startup/login attempt.
| AutoSizeText( | ||
| '${_getGreeting(appLocalizations)} $name', | ||
| style: TextStyle( |
There was a problem hiding this comment.
The greeting is built by concatenating two localized fragments (greeting + name). This is not fully localizable (word order / punctuation / spacing differ by language). Prefer a single localized message with a {name} placeholder (e.g. per time-of-day greeting keys that include the name), and format it through l10n instead of string concatenation.
| } else { | ||
| DaoSecuredString.remove(key: _USER_DETAILS); | ||
| } |
There was a problem hiding this comment.
DaoSecuredString.remove returns a Future, but this call isn’t awaited. That can leave user_details undeleted when subsequent logic runs (and also hides storage errors). Await the remove call (and consider propagating/handling the returned bool) before notifying listeners.
| DaoSecuredString.remove(key: _USER_ID); | ||
| DaoSecuredString.remove(key: _PASSWORD); | ||
| DaoSecuredString.remove(key: _COOKIE); | ||
| DaoSecuredString.remove(key: _USER_DETAILS); | ||
| notifyListeners(); | ||
| final bool contains = await credentialsInStorage(); | ||
| return !contains; |
There was a problem hiding this comment.
logout() calls DaoSecuredString.remove (async) without awaiting any of them, then immediately calls credentialsInStorage(). Because deletes may not have completed, logout can incorrectly report that credentials still exist. Await the removals (e.g. Future.wait) before checking credentialsInStorage / returning.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
… into 7372_greet_username
We will display We can use UI sample for a long text when used with
|
|
Copilot just suggested to add #7421 (comment) |

What
This PR updates the Community page header to display the user's real name (when available) along with a greeting instead of just showing the
userid(while userid serves as fallback when name isn't available)userDetailsfromLoginStatusduring login flow and added toLoginResultclass.globalUserDetailsstatic variable inUserManagementProviderfor global accessDaoSecuredStringScreenshot or video
Fixes bug(s)