Removed AuthenticationType.none
This commit is contained in:
parent
b019360ad1
commit
543a9d81b9
|
@ -12,15 +12,15 @@ class AuthenticationService {
|
||||||
|
|
||||||
|
|
||||||
var authenticationType: AuthenticationType {
|
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 {
|
var needsAuthenticationToUnlockApp: Bool {
|
||||||
let authenticationType = self.authenticationType
|
let authenticationType = self.authenticationType
|
||||||
|
|
||||||
return authenticationType != .unset && authenticationType != .none
|
return authenticationType != .none
|
||||||
}
|
}
|
||||||
|
|
||||||
var needsBiometricAuthenticationToUnlockApp: Bool {
|
var needsBiometricAuthenticationToUnlockApp: Bool {
|
||||||
|
@ -52,17 +52,12 @@ class AuthenticationService {
|
||||||
|
|
||||||
|
|
||||||
func setAuthenticationType(_ type: AuthenticationType) {
|
func setAuthenticationType(_ type: AuthenticationType) {
|
||||||
if type != .unset { // it's not allowed to unset authentication type
|
|
||||||
if needsPasswordToUnlockApp {
|
if needsPasswordToUnlockApp {
|
||||||
deleteLoginPassword()
|
deleteLoginPassword()
|
||||||
}
|
}
|
||||||
|
|
||||||
UserDefaults.standard.set(type.rawValue, forKey: Self.AuthenticationTypeUserDefaultsKey)
|
UserDefaults.standard.set(type.rawValue, forKey: Self.AuthenticationTypeUserDefaultsKey)
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
// TODO: what to do in this case, throw an exception?
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func setAuthenticationTypeToPassword(_ newPassword: String) {
|
func setAuthenticationTypeToPassword(_ newPassword: String) {
|
||||||
setAuthenticationType(.password)
|
setAuthenticationType(.password)
|
||||||
|
|
|
@ -3,8 +3,6 @@ import Foundation
|
||||||
|
|
||||||
enum AuthenticationType: String {
|
enum AuthenticationType: String {
|
||||||
|
|
||||||
case unset
|
|
||||||
|
|
||||||
case none
|
case none
|
||||||
|
|
||||||
case password
|
case password
|
||||||
|
|
|
@ -99,8 +99,7 @@ struct AddAccountDialog: View {
|
||||||
self.closeDialog()
|
self.closeDialog()
|
||||||
|
|
||||||
let authenticationService = AuthenticationService()
|
let authenticationService = AuthenticationService()
|
||||||
if self.presenter.allBanks.count == 1 && authenticationService.authenticationType == .unset {
|
if self.presenter.allBanks.count == 1 && authenticationService.authenticationType == .none {
|
||||||
authenticationService.setAuthenticationType(.none)
|
|
||||||
|
|
||||||
UIAlert("Secure data?", "Secure data with?",
|
UIAlert("Secure data?", "Secure data with?",
|
||||||
UIAlertAction.default("Yes") { SceneDelegate.navigateToView(ProtectAppSettingsDialog()) },
|
UIAlertAction.default("Yes") { SceneDelegate.navigateToView(ProtectAppSettingsDialog()) },
|
||||||
|
|
Loading…
Reference in New Issue