Removed AuthenticationType.none

This commit is contained in:
dankito 2020-10-02 02:25:39 +02:00
parent b019360ad1
commit 543a9d81b9
3 changed files with 9 additions and 17 deletions

View File

@ -12,15 +12,15 @@ class AuthenticationService {
var authenticationType: AuthenticationType {
let authenticationTypeString = UserDefaults.standard.string(forKey: Self.AuthenticationTypeUserDefaultsKey, defaultValue: AuthenticationType.unset.rawValue)
let authenticationTypeString = UserDefaults.standard.string(forKey: Self.AuthenticationTypeUserDefaultsKey, defaultValue: AuthenticationType.none.rawValue)
return AuthenticationType.init(rawValue: authenticationTypeString) ?? .unset
return AuthenticationType.init(rawValue: authenticationTypeString) ?? .none
}
var needsAuthenticationToUnlockApp: Bool {
let authenticationType = self.authenticationType
return authenticationType != .unset && authenticationType != .none
return authenticationType != .none
}
var needsBiometricAuthenticationToUnlockApp: Bool {
@ -52,16 +52,11 @@ class AuthenticationService {
func setAuthenticationType(_ type: AuthenticationType) {
if type != .unset { // it's not allowed to unset authentication type
if needsPasswordToUnlockApp {
deleteLoginPassword()
}
if needsPasswordToUnlockApp {
deleteLoginPassword()
}
UserDefaults.standard.set(type.rawValue, forKey: Self.AuthenticationTypeUserDefaultsKey)
}
else {
// TODO: what to do in this case, throw an exception?
}
UserDefaults.standard.set(type.rawValue, forKey: Self.AuthenticationTypeUserDefaultsKey)
}
func setAuthenticationTypeToPassword(_ newPassword: String) {

View File

@ -3,8 +3,6 @@ import Foundation
enum AuthenticationType: String {
case unset
case none
case password

View File

@ -99,8 +99,7 @@ struct AddAccountDialog: View {
self.closeDialog()
let authenticationService = AuthenticationService()
if self.presenter.allBanks.count == 1 && authenticationService.authenticationType == .unset {
authenticationService.setAuthenticationType(.none)
if self.presenter.allBanks.count == 1 && authenticationService.authenticationType == .none {
UIAlert("Secure data?", "Secure data with?",
UIAlertAction.default("Yes") { SceneDelegate.navigateToView(ProtectAppSettingsDialog()) },