π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
fix(auth): store error in Code
Prateek Sunal0810967aaec5
diff --git a/auth/lib/models/code.dart b/auth/lib/models/code.dartindex 9bf89c1a15..ba66e24655 100644--- a/auth/lib/models/code.dart+++ b/auth/lib/models/code.dart@@ -26,6 +26,9 @@ class Code {bool get isPinned => display.pinned;+ final Object? err;+ bool get hasError => err != null;+Code(this.account,this.issuer,@@ -38,8 +41,25 @@ class Code {this.rawData, {this.generatedID,required this.display,+ this.err,});+ factory Code.withError(Object error) {+ return Code(+ "",+ "",+ 0,+ 0,+ "",+ Algorithm.sha1,+ Type.totp,+ 0,+ "",+ err: error,+ display: CodeDisplay(),+ );+ }+Code copyWith({String? account,String? issuer,@@ -123,7 +143,7 @@ class Code {if (rawData.contains("#")) {return Code.fromOTPAuthUrl(rawData.replaceAll("#", '%23'));} else {- rethrow;+ return Code.withError(e);}}}diff --git a/auth/lib/store/code_store.dart b/auth/lib/store/code_store.dartindex 81c2d2dca1..946bbeb7bc 100644--- a/auth/lib/store/code_store.dart+++ b/auth/lib/store/code_store.dart@@ -31,22 +31,22 @@ class CodeStore {bool hasError = false;for (final entity in entities) {- try {- final decodeJson = jsonDecode(entity.rawData);-- late Code code;- if (decodeJson is String && decodeJson.startsWith('otpauth://')) {- code = Code.fromOTPAuthUrl(decodeJson);- } else {- code = Code.fromExportJson(decodeJson);- }- code.generatedID = entity.generatedID;- code.hasSynced = entity.hasSynced;- codes.add(code);- } catch (e) {+ final decodeJson = jsonDecode(entity.rawData);++ late Code code;+ if (decodeJson is String && decodeJson.startsWith('otpauth://')) {+ code = Code.fromOTPAuthUrl(decodeJson);+ } else {+ code = Code.fromExportJson(decodeJson);+ }+ if (code.hasError) {hasError = true;- _logger.severe("Could not parse code", e);+ _logger.severe("Could not parse code", code.err);+ continue;}+ code.generatedID = entity.generatedID;+ code.hasSynced = entity.hasSynced;+ codes.add(code);}// sort codes by issuer,account