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..cdd68642920 100644 --- a/Client/Frontend/AuthenticationManager/BasePasscodeViewController.swift +++ b/Client/Frontend/AuthenticationManager/BasePasscodeViewController.swift @@ -5,6 +5,7 @@ import Foundation import Shared import SwiftKeychainWrapper +import BraveShared /// Base UIViewController subclass containing methods for displaying common error messaging /// for the various Passcode configuration screens. @@ -62,7 +63,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() {