Removed AuthenticationType.none
This commit is contained in:
parent
b019360ad1
commit
543a9d81b9
|
@ -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) {
|
||||
|
|
|
@ -3,8 +3,6 @@ import Foundation
|
|||
|
||||
enum AuthenticationType: String {
|
||||
|
||||
case unset
|
||||
|
||||
case none
|
||||
|
||||
case password
|
||||
|
|
|
@ -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()) },
|
||||
|
|
Loading…
Reference in New Issue