Implemented setting device specific biometric authentication type

This commit is contained in:
dankito 2020-10-08 17:45:18 +02:00
parent c73628539a
commit b564fe15c2
5 changed files with 17 additions and 13 deletions

View File

@ -82,7 +82,7 @@
"Error message from your bank %@" = "Error message from your bank:\n\n%@"; "Error message from your bank %@" = "Error message from your bank:\n\n%@";
"Secure data?" = "Secure data?"; "Secure data?" = "Secure data?";
"Secure data with?" = "Adding account was successful.\n\nDo you want to secure your data and login passwords by password, TouchID or FaceID (if available)?\n\nYou can also do this later in the settings."; "Secure data with password or %@?" = "Successfully added account.\n\nYour data gets stored encrypted. Do you additionally want to secure your data by password or %@?\n\nYou can also do this later in the settings.";
/* AccountTransactionsDialog */ /* AccountTransactionsDialog */

View File

@ -58,6 +58,15 @@ class AuthenticationService {
return biometricAuthenticationService.isTouchIDSupported return biometricAuthenticationService.isTouchIDSupported
} }
var supportedBiometricAuthenticationLocalizedName: String {
if deviceSupportsTouchID {
return "TouchID".localize()
}
else {
return "FaceID".localize()
}
}
func setAuthenticationMethodToPassword(_ newPassword: String) { func setAuthenticationMethodToPassword(_ newPassword: String) {
setAuthenticationType(.password) setAuthenticationType(.password)

View File

@ -81,8 +81,8 @@
"Could not add account" = "Konto konnte nicht hinzugefügt werden."; "Could not add account" = "Konto konnte nicht hinzugefügt werden.";
"Error message from your bank %@" = "Fehlermeldung Ihrer Bank:\n\n%@"; "Error message from your bank %@" = "Fehlermeldung Ihrer Bank:\n\n%@";
"Secure data?" = "Daten schützen?"; "Secure data?" = "Appzugang schützen?";
"Secure data with?" = "Hinuzufügen war erfolgreich.\n\nMöchten Sie Ihre Daten und Anmeldekennwörter durch Passwort, TouchID oder FaceID (falls vorhanden) schützen?\n\nSie können dies auch später in den Einstellungen vornehmen."; "Secure data with password or %@?" = "Konto erfolgreich hinzugefügt.\n\nIhre Daten werden verschlüsselt gespeichert. Möchten Sie zusätzlich den Appzugang durch Passwort oder %@ schützen?\n\nSie können dies auch später in den Einstellungen vornehmen.";
/* AccountTransactionsDialog */ /* AccountTransactionsDialog */

View File

@ -110,7 +110,7 @@ struct AddAccountDialog: View {
let authenticationService = AuthenticationService() let authenticationService = AuthenticationService()
if self.presenter.allBanks.count == 1 && authenticationService.authenticationType == .none { if self.presenter.allBanks.count == 1 && authenticationService.authenticationType == .none {
UIAlert("Secure data?", "Secure data with?", UIAlert("Secure data?", "Secure data with password or %@?".localize(authenticationService.supportedBiometricAuthenticationLocalizedName),
UIAlertAction.default("Yes") { SceneDelegate.navigateToView(ProtectAppSettingsDialog()) }, UIAlertAction.default("Yes") { SceneDelegate.navigateToView(ProtectAppSettingsDialog()) },
UIAlertAction.cancel("Later", self.closeDialog)) UIAlertAction.cancel("Later", self.closeDialog))
.show() .show()

View File

@ -144,7 +144,7 @@ struct ProtectAppSettingsDialog: View {
private func getAuthenticationTypeLabel(_ type: AuthenticationType) -> LocalizedStringKey { private func getAuthenticationTypeLabel(_ type: AuthenticationType) -> LocalizedStringKey {
switch type { switch type {
case .biometric: case .biometric:
return LocalizedStringKey(supportedBiometricAuthenticationTitle) return LocalizedStringKey(supportedBiometricAuthenticationLocalizedName)
case .password: case .password:
return "Password" return "Password"
default: default:
@ -152,13 +152,8 @@ struct ProtectAppSettingsDialog: View {
} }
} }
private var supportedBiometricAuthenticationTitle: String { private var supportedBiometricAuthenticationLocalizedName: String {
if authenticationService.deviceSupportsTouchID { return authenticationService.supportedBiometricAuthenticationLocalizedName
return "TouchID"
}
else {
return "FaceID"
}
} }
private func selectedAuthenticationTypeChanged(_ type: AuthenticationType) { private func selectedAuthenticationTypeChanged(_ type: AuthenticationType) {
@ -188,7 +183,7 @@ struct ProtectAppSettingsDialog: View {
} }
private func doBiometricAuthentication() { private func doBiometricAuthentication() {
authenticationService.authenticateUserWithBiometric("Authenticate to encrypt data with %@".localize(supportedBiometricAuthenticationTitle.localize())) { success, errorMessage in authenticationService.authenticateUserWithBiometric("Authenticate to encrypt data with %@".localize(supportedBiometricAuthenticationLocalizedName)) { success, errorMessage in
self.successfullyAuthenticatedWithBiometricAuthentication = success self.successfullyAuthenticatedWithBiometricAuthentication = success
} }
} }