From 321eb9ebe3532cfc0ce5f544204b4084dd9fd9e1 Mon Sep 17 00:00:00 2001 From: Edouard Marquez Date: Sat, 20 Apr 2024 15:20:30 +0200 Subject: [PATCH] The user's cookie is now stored and passed to the API (#5170) --- .../cache/nutriscore-a-new-formula-en.svg | 1 + .../cache/nutriscore-b-new-formula-en.svg | 1 + .../cache/nutriscore-c-new-formula-en.svg | 1 + .../cache/nutriscore-d-new-formula-en.svg | 1 + .../cache/nutriscore-e-new-formula-en.svg | 1 + ...triscore-not-applicable-new-formula-en.svg | 317 +++++++++++++++++ .../nutriscore-unknown-new-formula-en.svg | 318 ++++++++++++++++++ .../lib/data_models/login_result.dart | 1 + .../data_models/user_management_provider.dart | 24 +- packages/smooth_app/macos/Podfile.lock | 37 +- .../macos/Runner.xcodeproj/project.pbxproj | 2 +- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- packages/smooth_app/pubspec.lock | 134 ++++---- packages/smooth_app/pubspec.yaml | 2 +- 14 files changed, 748 insertions(+), 94 deletions(-) create mode 100644 packages/smooth_app/assets/cache/nutriscore-a-new-formula-en.svg create mode 100644 packages/smooth_app/assets/cache/nutriscore-b-new-formula-en.svg create mode 100644 packages/smooth_app/assets/cache/nutriscore-c-new-formula-en.svg create mode 100644 packages/smooth_app/assets/cache/nutriscore-d-new-formula-en.svg create mode 100644 packages/smooth_app/assets/cache/nutriscore-e-new-formula-en.svg create mode 100644 packages/smooth_app/assets/cache/nutriscore-not-applicable-new-formula-en.svg create mode 100644 packages/smooth_app/assets/cache/nutriscore-unknown-new-formula-en.svg diff --git a/packages/smooth_app/assets/cache/nutriscore-a-new-formula-en.svg b/packages/smooth_app/assets/cache/nutriscore-a-new-formula-en.svg new file mode 100644 index 00000000000..6516f55c498 --- /dev/null +++ b/packages/smooth_app/assets/cache/nutriscore-a-new-formula-en.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/packages/smooth_app/assets/cache/nutriscore-b-new-formula-en.svg b/packages/smooth_app/assets/cache/nutriscore-b-new-formula-en.svg new file mode 100644 index 00000000000..f973754dc27 --- /dev/null +++ b/packages/smooth_app/assets/cache/nutriscore-b-new-formula-en.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/packages/smooth_app/assets/cache/nutriscore-c-new-formula-en.svg b/packages/smooth_app/assets/cache/nutriscore-c-new-formula-en.svg new file mode 100644 index 00000000000..7e208163e3f --- /dev/null +++ b/packages/smooth_app/assets/cache/nutriscore-c-new-formula-en.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/packages/smooth_app/assets/cache/nutriscore-d-new-formula-en.svg b/packages/smooth_app/assets/cache/nutriscore-d-new-formula-en.svg new file mode 100644 index 00000000000..8a0ff49d8cd --- /dev/null +++ b/packages/smooth_app/assets/cache/nutriscore-d-new-formula-en.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/packages/smooth_app/assets/cache/nutriscore-e-new-formula-en.svg b/packages/smooth_app/assets/cache/nutriscore-e-new-formula-en.svg new file mode 100644 index 00000000000..f6c74eda004 --- /dev/null +++ b/packages/smooth_app/assets/cache/nutriscore-e-new-formula-en.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/packages/smooth_app/assets/cache/nutriscore-not-applicable-new-formula-en.svg b/packages/smooth_app/assets/cache/nutriscore-not-applicable-new-formula-en.svg new file mode 100644 index 00000000000..bcb99574253 --- /dev/null +++ b/packages/smooth_app/assets/cache/nutriscore-not-applicable-new-formula-en.svg @@ -0,0 +1,317 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/smooth_app/assets/cache/nutriscore-unknown-new-formula-en.svg b/packages/smooth_app/assets/cache/nutriscore-unknown-new-formula-en.svg new file mode 100644 index 00000000000..407614599c9 --- /dev/null +++ b/packages/smooth_app/assets/cache/nutriscore-unknown-new-formula-en.svg @@ -0,0 +1,318 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/smooth_app/lib/data_models/login_result.dart b/packages/smooth_app/lib/data_models/login_result.dart index 95411c9d7d1..7828962402e 100644 --- a/packages/smooth_app/lib/data_models/login_result.dart +++ b/packages/smooth_app/lib/data_models/login_result.dart @@ -51,6 +51,7 @@ class LoginResult { user: User( userId: loginStatus.userId!, password: user.password, + cookie: loginStatus.cookie, ), ); } catch (e) { diff --git a/packages/smooth_app/lib/data_models/user_management_provider.dart b/packages/smooth_app/lib/data_models/user_management_provider.dart index ca8e09e05aa..e1d02a40d8a 100644 --- a/packages/smooth_app/lib/data_models/user_management_provider.dart +++ b/packages/smooth_app/lib/data_models/user_management_provider.dart @@ -9,6 +9,7 @@ import 'package:smooth_app/services/smooth_services.dart'; class UserManagementProvider with ChangeNotifier { static const String _USER_ID = 'user_id'; static const String _PASSWORD = 'pasword'; + static const String _COOKIE = 'user_cookie'; /// Checks credentials and conditionally saves them. Future login(final User user) async { @@ -26,6 +27,7 @@ class UserManagementProvider with ChangeNotifier { OpenFoodAPIConfiguration.globalUser = null; DaoSecuredString.remove(key: _USER_ID); DaoSecuredString.remove(key: _PASSWORD); + DaoSecuredString.remove(key: _COOKIE); notifyListeners(); final bool contains = await credentialsInStorage(); return !contains; @@ -38,24 +40,32 @@ class UserManagementProvider with ChangeNotifier { {String? userId, String? password}) async { String? effectiveUserId; String? effectivePassword; + String? effectiveCookie; try { effectiveUserId = userId ?? await DaoSecuredString.get(_USER_ID); effectivePassword = password ?? await DaoSecuredString.get(_PASSWORD); + effectiveCookie = password ?? await DaoSecuredString.get(_COOKIE); } on PlatformException { /// Decrypting the values can go wrong if, for example, the app was /// manually overwritten from an external apk. DaoSecuredString.remove(key: _USER_ID); DaoSecuredString.remove(key: _PASSWORD); + DaoSecuredString.remove(key: _COOKIE); Logs.e('Credentials query failed, you have been logged out'); } - if (effectiveUserId == null || effectivePassword == null) { + if (effectiveUserId == null || + effectivePassword == null || + effectiveCookie == null) { return; } - final User user = - User(userId: effectiveUserId, password: effectivePassword); + final User user = User( + userId: effectiveUserId, + password: effectivePassword, + cookie: effectiveCookie, + ); OpenFoodAPIConfiguration.globalUser = user; } @@ -78,6 +88,14 @@ class UserManagementProvider with ChangeNotifier { key: _PASSWORD, value: user.password, ); + if (user.cookie != null) { + await DaoSecuredString.put( + key: _COOKIE, + value: user.cookie!, + ); + } else { + DaoSecuredString.remove(key: _COOKIE); + } notifyListeners(); } diff --git a/packages/smooth_app/macos/Podfile.lock b/packages/smooth_app/macos/Podfile.lock index 0630889c000..72808270949 100644 --- a/packages/smooth_app/macos/Podfile.lock +++ b/packages/smooth_app/macos/Podfile.lock @@ -13,9 +13,6 @@ PODS: - flutter_secure_storage_macos (6.1.1): - FlutterMacOS - FlutterMacOS (1.0.0) - - FMDB (2.7.5): - - FMDB/standard (= 2.7.5) - - FMDB/standard (2.7.5) - in_app_review (0.2.0): - FlutterMacOS - mobile_scanner (3.5.2): @@ -25,24 +22,24 @@ PODS: - path_provider_foundation (0.0.1): - Flutter - FlutterMacOS - - ReachabilitySwift (5.0.0) + - ReachabilitySwift (5.2.2) - rive_common (0.0.1): - FlutterMacOS - - Sentry/HybridSDK (8.15.2): - - SentryPrivate (= 8.15.2) + - Sentry/HybridSDK (8.21.0): + - SentryPrivate (= 8.21.0) - sentry_flutter (0.0.1): - Flutter - FlutterMacOS - - Sentry/HybridSDK (= 8.15.2) - - SentryPrivate (8.15.2) + - Sentry/HybridSDK (= 8.21.0) + - SentryPrivate (8.21.0) - share_plus (0.0.1): - FlutterMacOS - shared_preferences_foundation (0.0.1): - Flutter - FlutterMacOS - - sqflite (0.0.2): + - sqflite (0.0.3): + - Flutter - FlutterMacOS - - FMDB (>= 2.7.5) - url_launcher_macos (0.0.1): - FlutterMacOS @@ -62,12 +59,11 @@ DEPENDENCIES: - sentry_flutter (from `Flutter/ephemeral/.symlinks/plugins/sentry_flutter/macos`) - share_plus (from `Flutter/ephemeral/.symlinks/plugins/share_plus/macos`) - shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin`) - - sqflite (from `Flutter/ephemeral/.symlinks/plugins/sqflite/macos`) + - sqflite (from `Flutter/ephemeral/.symlinks/plugins/sqflite/darwin`) - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) SPEC REPOS: trunk: - - FMDB - ReachabilitySwift - Sentry - SentryPrivate @@ -104,7 +100,7 @@ EXTERNAL SOURCES: shared_preferences_foundation: :path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin sqflite: - :path: Flutter/ephemeral/.symlinks/plugins/sqflite/macos + :path: Flutter/ephemeral/.symlinks/plugins/sqflite/darwin url_launcher_macos: :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos @@ -116,21 +112,20 @@ SPEC CHECKSUMS: flutter_image_compress_macos: c26c3c13ea0f28ae6dea4e139b3292e7729f99f1 flutter_secure_storage_macos: d56e2d218c1130b262bef8b4a7d64f88d7f9c9ea FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 - FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a in_app_review: a850789fad746e89bce03d4aeee8078b45a53fd0 mobile_scanner: 621cf2c34e1c74ae7ce5c6793638ab600723bdea package_info_plus: 02d7a575e80f194102bef286361c6c326e4c29ce path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c - ReachabilitySwift: 985039c6f7b23a1da463388634119492ff86c825 - rive_common: 0f0aadf670f0c6a7872dfe3e6186f112a5319108 - Sentry: 6f5742b4c47c17c9adcf265f6f328cf4a0ed1923 - sentry_flutter: 2c309a1d4b45e59d02cfa15795705687f1e2081b - SentryPrivate: b2f7996f37781080f04a946eb4e377ff63c64195 + ReachabilitySwift: 2128f3a8c9107e1ad33574c6e58e8285d460b149 + rive_common: 90d667125afd74095b697cf7d2d2e9c50813ec8c + Sentry: ebc12276bd17613a114ab359074096b6b3725203 + sentry_flutter: dff1df05dc39c83d04f9330b36360fc374574c5e + SentryPrivate: d651efb234cf385ec9a1cdd3eff94b5e78a0e0fe share_plus: 76dd39142738f7a68dd57b05093b5e8193f220f7 shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695 - sqflite: a5789cceda41d54d23f31d6de539d65bb14100ea + sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec url_launcher_macos: d2691c7dd33ed713bf3544850a623080ec693d95 PODFILE CHECKSUM: 0d3963a09fc94f580682bd88480486da345dc3f0 -COCOAPODS: 1.14.3 +COCOAPODS: 1.15.2 diff --git a/packages/smooth_app/macos/Runner.xcodeproj/project.pbxproj b/packages/smooth_app/macos/Runner.xcodeproj/project.pbxproj index faac40d0aa8..d0a22a97b03 100644 --- a/packages/smooth_app/macos/Runner.xcodeproj/project.pbxproj +++ b/packages/smooth_app/macos/Runner.xcodeproj/project.pbxproj @@ -202,7 +202,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0920; - LastUpgradeCheck = 1430; + LastUpgradeCheck = 1510; ORGANIZATIONNAME = ""; TargetAttributes = { 33CC10EC2044A3C60003C045 = { diff --git a/packages/smooth_app/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/packages/smooth_app/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 5ebb5d0af52..16f4c2a3299 100644 --- a/packages/smooth_app/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/packages/smooth_app/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ =3.3.3 <4.0.0" - flutter: ">=3.16.0" + flutter: ">=3.19.0" diff --git a/packages/smooth_app/pubspec.yaml b/packages/smooth_app/pubspec.yaml index 0d26d3c9f1d..8bdd6e20c1a 100644 --- a/packages/smooth_app/pubspec.yaml +++ b/packages/smooth_app/pubspec.yaml @@ -98,7 +98,7 @@ dependencies: path: ../scanner/zxing - openfoodfacts: 3.5.0 + openfoodfacts: 3.6.0 # openfoodfacts: # path: ../../../openfoodfacts-dart