From 547725589b50bbe3190f4555a708158f5002c3a3 Mon Sep 17 00:00:00 2001 From: DGoiana Date: Wed, 19 Jun 2024 21:01:39 +0100 Subject: [PATCH] fixing password encoding in local storage --- .../controller/local_storage/preferences_controller.dart | 9 +++------ uni/pubspec.lock | 4 ++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/uni/lib/controller/local_storage/preferences_controller.dart b/uni/lib/controller/local_storage/preferences_controller.dart index 71b103838..dad032cda 100644 --- a/uni/lib/controller/local_storage/preferences_controller.dart +++ b/uni/lib/controller/local_storage/preferences_controller.dart @@ -79,7 +79,7 @@ class PreferencesController { List faculties, ) async { await _secureStorage.write(key: _userNumber, value: user); - await _secureStorage.write(key: _userPw, value: pass); + await _secureStorage.write(key: _userPw, value: encode(pass)); await prefs.setStringList( _userFaculties, faculties, @@ -175,6 +175,7 @@ class PreferencesController { static Future?> getPersistentUserInfo() async { final userNum = await getUserNumber(); final userPass = await getUserPassword(); + if (userNum == null || userPass == null) { return null; } @@ -281,11 +282,7 @@ class PreferencesController { /// Decrypts [base64Text]. static String? decode(String base64Text) { final encrypter = _createEncrypter(); - try { - return encrypter.decrypt64(base64Text, iv: iv); - } catch (_) { - return null; - } + return encrypter.decrypt64(base64Text, iv: iv); } /// Creates an [encrypt.Encrypter] for encrypting and decrypting the user's diff --git a/uni/pubspec.lock b/uni/pubspec.lock index c6912a129..be68b945d 100644 --- a/uni/pubspec.lock +++ b/uni/pubspec.lock @@ -1343,10 +1343,10 @@ packages: dependency: "direct main" description: name: ua_client_hints - sha256: "8401d7bec261f61b3d3b61cd877653ddf840de2d9e07bd164f34588572aa0c8b" + sha256: ee3da4e4b6ed211fe54deaa19832dd25613f11fc2951912d4e62a093da03fbbb url: "https://pub.dev" source: hosted - version: "1.2.2" + version: "1.3.1" unicode: dependency: transitive description: