From a925ab824a76bdd5939cc80510938c5367006998 Mon Sep 17 00:00:00 2001 From: Kyle Hickinson Date: Mon, 18 Nov 2019 11:46:56 -0500 Subject: [PATCH] Fix #443: Display time out details for incorrect passcode lockdown --- BraveShared/BraveStrings.swift | 4 +++- .../BasePasscodeViewController.swift | 11 ++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/BraveShared/BraveStrings.swift b/BraveShared/BraveStrings.swift index 436ba85764c..9bb4f3bee5a 100644 --- a/BraveShared/BraveStrings.swift +++ b/BraveShared/BraveStrings.swift @@ -288,7 +288,9 @@ extension Strings { public static let AuthenticationIncorrectAttemptsRemaining = NSLocalizedString("AuthenticationIncorrectAttemptsRemaining", tableName: "BraveShared", bundle: Bundle.braveShared, value: "Incorrect passcode. Try again (Attempts remaining: %d).", comment: "Error message displayed when user enters incorrect passcode when trying to enter a protected section of the app with attempts remaining") - public static let AuthenticationMaximumAttemptsReached = NSLocalizedString("AuthenticationMaximumAttemptsReached", tableName: "BraveShared", bundle: Bundle.braveShared, value: "Maximum attempts reached. Please try again in an hour.", comment: "Error message displayed when user enters incorrect passcode and has reached the maximum number of attempts.") + public static let AuthenticationMaximumAttemptsReached = NSLocalizedString("AuthenticationMaximumAttemptsReached", tableName: "BraveShared", bundle: Bundle.braveShared, value: "Too many failed attempts. Please try again in %d minutes.", comment: "Error message displayed when user enters incorrect passcode and has reached the maximum number of attempts.") + + public static let AuthenticationMaximumAttemptsReachedOneMinute = NSLocalizedString("AuthenticationMaximumAttemptsReachedOneMinute", tableName: "BraveShared", bundle: Bundle.braveShared, value: "Too many failed attempts. Please try again in 1 minute.", comment: "Error message displayed when user enters incorrect passcode and has reached the maximum number of attempts.") public static let AuthenticationMaximumAttemptsReachedNoTime = NSLocalizedString("AuthenticationMaximumAttemptsReachedNoTime", tableName: "BraveShared", bundle: Bundle.braveShared, value: "Maximum attempts reached. Please try again later.", comment: "Error message displayed when user enters incorrect passcode and has reached the maximum number of attempts.") diff --git a/Client/Frontend/AuthenticationManager/BasePasscodeViewController.swift b/Client/Frontend/AuthenticationManager/BasePasscodeViewController.swift index 19ee1beced9..42e7f371c93 100644 --- a/Client/Frontend/AuthenticationManager/BasePasscodeViewController.swift +++ b/Client/Frontend/AuthenticationManager/BasePasscodeViewController.swift @@ -62,7 +62,16 @@ extension BasePasscodeViewController { } func displayLockoutError() { - displayError(Strings.AuthenticationMaximumAttemptsReachedNoTime) + if let timeLeft = authenticationInfo?.lockoutTimeLeft { + let inMinutes = Int(ceil(timeLeft / 60)) + if inMinutes == 1 { + displayError(Strings.AuthenticationMaximumAttemptsReachedOneMinute) + } else { + displayError(String.localizedStringWithFormat(Strings.AuthenticationMaximumAttemptsReached, inMinutes)) + } + } else { + displayError(Strings.AuthenticationMaximumAttemptsReachedNoTime) + } } func failMismatchPasscode() {