Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Fix #443: Display time out details for incorrect passcode lockdown
Browse files Browse the repository at this point in the history
  • Loading branch information
kylehickinson committed Nov 18, 2019
1 parent eb689ba commit b064eae
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 3 additions & 1 deletion BraveShared/BraveStrings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit b064eae

Please sign in to comment.