From 1d8ada1fc032bc83f54d10dc782486269d91563e Mon Sep 17 00:00:00 2001 From: Ermat Date: Fri, 29 Sep 2023 15:51:31 +0600 Subject: [PATCH] Validate if new passcode is already used --- .../Modules/Passcode/Manage/SetPasscodeViewModel.swift | 8 ++++++++ .../UnstoppableWallet/en.lproj/Localizable.strings | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/Passcode/Manage/SetPasscodeViewModel.swift b/UnstoppableWallet/UnstoppableWallet/Modules/Passcode/Manage/SetPasscodeViewModel.swift index 5f7ea5d919..45b85b8ed9 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/Passcode/Manage/SetPasscodeViewModel.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/Passcode/Manage/SetPasscodeViewModel.swift @@ -1,4 +1,5 @@ import Combine +import UIKit class SetPasscodeViewModel: ObservableObject { let passcodeLength = 6 @@ -17,6 +18,7 @@ class SetPasscodeViewModel: ObservableObject { } } } + @Published var shakeTrigger: Int = 0 let passcodeManager: PasscodeManager @@ -47,6 +49,12 @@ class SetPasscodeViewModel: ObservableObject { syncDescription() errorText = "set_passcode.invalid_confirmation".localized } + } else if passcodeManager.has(passcode: passcode) { + passcode = "" + errorText = "set_passcode.already_used".localized + + shakeTrigger += 1 + UINotificationFeedbackGenerator().notificationOccurred(.error) } else { enteredPasscode = passcode passcode = "" diff --git a/UnstoppableWallet/UnstoppableWallet/en.lproj/Localizable.strings b/UnstoppableWallet/UnstoppableWallet/en.lproj/Localizable.strings index 7e8f5f63f3..92c631324b 100644 --- a/UnstoppableWallet/UnstoppableWallet/en.lproj/Localizable.strings +++ b/UnstoppableWallet/UnstoppableWallet/en.lproj/Localizable.strings @@ -1131,7 +1131,8 @@ Go to Settings - > %@ and allow access to the camera."; // Set Passcode -"set_passcode.invalid_confirmation" = "Invalid Confirmation"; +"set_passcode.invalid_confirmation" = "Invalid confirmation"; +"set_passcode.already_used" = "This passcode is already being used"; // Unlock