Skip to content

Commit

Permalink
fixing password encoding in local storage (#1245)
Browse files Browse the repository at this point in the history
  • Loading branch information
DGoiana authored Jun 19, 2024
2 parents 36b0f44 + 5477255 commit 07e18da
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
9 changes: 3 additions & 6 deletions uni/lib/controller/local_storage/preferences_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class PreferencesController {
List<String> 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,
Expand Down Expand Up @@ -175,6 +175,7 @@ class PreferencesController {
static Future<Tuple2<String, String>?> getPersistentUserInfo() async {
final userNum = await getUserNumber();
final userPass = await getUserPassword();

if (userNum == null || userPass == null) {
return null;
}
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions uni/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 07e18da

Please sign in to comment.