Skip to content

Commit

Permalink
Validate if new passcode is already used
Browse files Browse the repository at this point in the history
  • Loading branch information
ealymbaev committed Sep 29, 2023
1 parent 4f873bc commit 1d8ada1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Combine
import UIKit

class SetPasscodeViewModel: ObservableObject {
let passcodeLength = 6
Expand All @@ -17,6 +18,7 @@ class SetPasscodeViewModel: ObservableObject {
}
}
}

@Published var shakeTrigger: Int = 0

let passcodeManager: PasscodeManager
Expand Down Expand Up @@ -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 = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 1d8ada1

Please sign in to comment.