Extracted methods for each authentication type

This commit is contained in:
dankito 2020-10-02 03:50:25 +02:00
parent 2ca698f9e2
commit cd8055a141
2 changed files with 18 additions and 4 deletions

View File

@ -51,7 +51,21 @@ class AuthenticationService {
}
func setAuthenticationType(_ type: AuthenticationType) {
func setAuthenticationMethodToPassword(_ newPassword: String) {
setAuthenticationType(.password)
setLoginPassword(newPassword)
}
func setAuthenticationMethodToBiometric() {
setAuthenticationType(.biometric)
}
func removeAppProtection() {
setAuthenticationType(.none)
}
private func setAuthenticationType(_ type: AuthenticationType) {
if needsPasswordToUnlockApp {
deleteLoginPassword()
}

View File

@ -193,13 +193,13 @@ struct ProtectAppSettingsDialog: View {
private func setAuthenticationType() {
if isFaceIDSelected || isTouchIDSelected {
authenticationService.setAuthenticationType(.biometric)
authenticationService.setAuthenticationMethodToBiometric()
}
else if isPasswordSelected {
authenticationService.setAuthenticationTypeToPassword(newPassword)
authenticationService.setAuthenticationMethodToPassword(newPassword)
}
else if isNoAppProtectionSelected {
authenticationService.setAuthenticationType(.none)
authenticationService.removeAppProtection()
}
presentation.wrappedValue.dismiss()