From b974ac269df471780c5544c82f80710bd5281319 Mon Sep 17 00:00:00 2001 From: zaelgohary Date: Thu, 31 Oct 2024 03:36:37 +0300 Subject: [PATCH 1/2] Prevent saving a pin that matches old one --- app/lib/screens/change_pin_screen.dart | 18 +++++++++++++++--- app/lib/screens/recover_screen.dart | 3 ++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/lib/screens/change_pin_screen.dart b/app/lib/screens/change_pin_screen.dart index 1e6c3d68c..76889a6e7 100644 --- a/app/lib/screens/change_pin_screen.dart +++ b/app/lib/screens/change_pin_screen.dart @@ -13,7 +13,7 @@ class ChangePinScreen extends StatefulWidget { State createState() => _ChangePinScreenState(); } -enum _State { newPinWrong, newPin, confirm, done } +enum _State { newPinWrong, sameOldPin, newPin, confirm, done } class _ChangePinScreenState extends State { String newPin = ''; @@ -27,6 +27,8 @@ class _ChangePinScreenState extends State { switch (state) { case _State.newPinWrong: return 'Confirmation incorrect, please enter your new PIN'; + case _State.sameOldPin: + return "New PIN can't match the old one"; case _State.newPin: return 'Please enter your new PIN'; case _State.confirm: @@ -57,8 +59,18 @@ class _ChangePinScreenState extends State { switch (state) { case _State.newPinWrong: case _State.newPin: - newPin = enteredPinCode; - state = _State.confirm; + if (enteredPinCode == widget.currentPin) { + state = _State.sameOldPin; + } else { + newPin = enteredPinCode; + state = _State.confirm; + } + break; + case _State.sameOldPin: + if (enteredPinCode != widget.currentPin) { + newPin = enteredPinCode; + state = _State.confirm; + } break; case _State.confirm: if (newPin == enteredPinCode) { diff --git a/app/lib/screens/recover_screen.dart b/app/lib/screens/recover_screen.dart index b82968377..e3426cb79 100644 --- a/app/lib/screens/recover_screen.dart +++ b/app/lib/screens/recover_screen.dart @@ -45,7 +45,8 @@ class _RecoverScreenState extends State { Map body = json.decode(userInfoResult.body); if (body['publicKey'] != base64.encode(keyPair.publicKey)) { - throw Exception('Seed phrase does not match with ${doubleName.replaceAll('.3bot', '')}'); + throw Exception( + 'Seed phrase does not match with ${doubleName.replaceAll('.3bot', '')}'); } } From f8ced6dae09e5eb52652a2b8a0a3c617321add83 Mon Sep 17 00:00:00 2001 From: Zainab Elgohary <40770501+zaelgohary@users.noreply.github.com> Date: Thu, 21 Nov 2024 14:48:04 +0200 Subject: [PATCH 2/2] Update app/lib/screens/change_pin_screen.dart Co-authored-by: AhmedHanafy725 <41957921+AhmedHanafy725@users.noreply.github.com> --- app/lib/screens/change_pin_screen.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/lib/screens/change_pin_screen.dart b/app/lib/screens/change_pin_screen.dart index 76889a6e7..37ac31d6e 100644 --- a/app/lib/screens/change_pin_screen.dart +++ b/app/lib/screens/change_pin_screen.dart @@ -28,7 +28,7 @@ class _ChangePinScreenState extends State { case _State.newPinWrong: return 'Confirmation incorrect, please enter your new PIN'; case _State.sameOldPin: - return "New PIN can't match the old one"; + return "New PIN must not match the old one"; case _State.newPin: return 'Please enter your new PIN'; case _State.confirm: