diff --git a/ui/BankingiOSApp/BankingiOSApp/Security/AuthenticationService.swift b/ui/BankingiOSApp/BankingiOSApp/Security/AuthenticationService.swift index 452b0696..0495f7de 100644 --- a/ui/BankingiOSApp/BankingiOSApp/Security/AuthenticationService.swift +++ b/ui/BankingiOSApp/BankingiOSApp/Security/AuthenticationService.swift @@ -12,15 +12,15 @@ class AuthenticationService { var authenticationType: AuthenticationType { - let authenticationTypeString = UserDefaults.standard.string(forKey: Self.AuthenticationTypeUserDefaultsKey, defaultValue: AuthenticationType.unset.rawValue) - - return AuthenticationType.init(rawValue: authenticationTypeString) ?? .unset + let authenticationTypeString = UserDefaults.standard.string(forKey: Self.AuthenticationTypeUserDefaultsKey, defaultValue: AuthenticationType.none.rawValue) + + 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() - } - - UserDefaults.standard.set(type.rawValue, forKey: Self.AuthenticationTypeUserDefaultsKey) - } - else { - // TODO: what to do in this case, throw an exception? + if needsPasswordToUnlockApp { + deleteLoginPassword() } + + UserDefaults.standard.set(type.rawValue, forKey: Self.AuthenticationTypeUserDefaultsKey) } func setAuthenticationTypeToPassword(_ newPassword: String) { diff --git a/ui/BankingiOSApp/BankingiOSApp/Security/AuthenticationType.swift b/ui/BankingiOSApp/BankingiOSApp/Security/AuthenticationType.swift index f92f056a..f0cd039e 100644 --- a/ui/BankingiOSApp/BankingiOSApp/Security/AuthenticationType.swift +++ b/ui/BankingiOSApp/BankingiOSApp/Security/AuthenticationType.swift @@ -3,8 +3,6 @@ import Foundation enum AuthenticationType: String { - case unset - case none case password diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AddAccountDialog.swift b/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AddAccountDialog.swift index c5055b50..c9140cb1 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AddAccountDialog.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AddAccountDialog.swift @@ -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()) },