Extracted methods for each authentication type
This commit is contained in:
parent
2ca698f9e2
commit
cd8055a141
|
@ -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 {
|
if needsPasswordToUnlockApp {
|
||||||
deleteLoginPassword()
|
deleteLoginPassword()
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,13 +193,13 @@ struct ProtectAppSettingsDialog: View {
|
||||||
|
|
||||||
private func setAuthenticationType() {
|
private func setAuthenticationType() {
|
||||||
if isFaceIDSelected || isTouchIDSelected {
|
if isFaceIDSelected || isTouchIDSelected {
|
||||||
authenticationService.setAuthenticationType(.biometric)
|
authenticationService.setAuthenticationMethodToBiometric()
|
||||||
}
|
}
|
||||||
else if isPasswordSelected {
|
else if isPasswordSelected {
|
||||||
authenticationService.setAuthenticationTypeToPassword(newPassword)
|
authenticationService.setAuthenticationMethodToPassword(newPassword)
|
||||||
}
|
}
|
||||||
else if isNoAppProtectionSelected {
|
else if isNoAppProtectionSelected {
|
||||||
authenticationService.setAuthenticationType(.none)
|
authenticationService.removeAppProtection()
|
||||||
}
|
}
|
||||||
|
|
||||||
presentation.wrappedValue.dismiss()
|
presentation.wrappedValue.dismiss()
|
||||||
|
|
Loading…
Reference in New Issue