Skip to content

Commit

Permalink
Merge pull request #693 from threefoldtech/development_fix_pin
Browse files Browse the repository at this point in the history
Prevent saving old pin
  • Loading branch information
zaelgohary authored Nov 21, 2024
2 parents 35281a1 + f8ced6d commit 5842a27
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions app/lib/screens/change_pin_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ChangePinScreen extends StatefulWidget {
State<ChangePinScreen> createState() => _ChangePinScreenState();
}

enum _State { newPinWrong, newPin, confirm, done }
enum _State { newPinWrong, sameOldPin, newPin, confirm, done }

class _ChangePinScreenState extends State<ChangePinScreen> {
String newPin = '';
Expand All @@ -27,6 +27,8 @@ class _ChangePinScreenState extends State<ChangePinScreen> {
switch (state) {
case _State.newPinWrong:
return 'Confirmation incorrect, please enter your new PIN';
case _State.sameOldPin:
return "New PIN must not match the old one";
case _State.newPin:
return 'Please enter your new PIN';
case _State.confirm:
Expand Down Expand Up @@ -57,8 +59,18 @@ class _ChangePinScreenState extends State<ChangePinScreen> {
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) {
Expand Down

0 comments on commit 5842a27

Please sign in to comment.