File tree Expand file tree Collapse file tree 4 files changed +9
-15
lines changed
Expand file tree Collapse file tree 4 files changed +9
-15
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import LocalAuthentication
1010
1111struct BiometricToggleView : View {
1212 @Binding var isEnabled : Bool
13- let onToggleOn : ( ) -> Void
13+ let onToggleOn : ( _ status : Bool ) -> Void
1414
1515 private var biometricToggleText : String {
1616 let context = LAContext ( )
@@ -24,12 +24,8 @@ struct BiometricToggleView: View {
2424 Toggle ( isOn: Binding (
2525 get: { isEnabled } ,
2626 set: { newValue in
27- let wasOff = !isEnabled
2827 isEnabled = newValue
29- if newValue && wasOff {
30- // User turned it on manually
31- onToggleOn ( )
32- }
28+ onToggleOn ( newValue)
3329 }
3430 ) ) {
3531 Text ( biometricToggleText)
Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ struct PasswordAuthenticationPopupView: View {
6363
6464 private func handleContinue( ) {
6565 let environment = APIConfiguration . shared. environment
66- let username = KeychainManager . load ( . username, for : environment ) ?? " "
66+ let username = SessionManager . shared . username ?? " "
6767
6868 viewModel. performBiometricEnrollment (
6969 username: username,
Original file line number Diff line number Diff line change @@ -45,7 +45,6 @@ final class SessionManager: ObservableObject {
4545
4646 case . failure( let error) :
4747 print ( " Login failed: " , error)
48- self ? . username = nil
4948 self ? . isLoginSuccessful = false
5049 self ? . hasLoginFailed = true
5150 completion ( false , " Invalid credentials " )
@@ -67,7 +66,6 @@ final class SessionManager: ObservableObject {
6766
6867 func logout( environment: APIEnvironment , clearBiometricCreds: Bool = false ) {
6968 if clearBiometricCreds {
70- _ = KeychainManager . delete ( . username, for: environment)
7169 _ = KeychainManager . delete ( . password, for: environment)
7270 setBiometricEnabled ( false , for: environment)
7371 }
Original file line number Diff line number Diff line change @@ -39,8 +39,12 @@ struct UserProfileView: View {
3939 }
4040 . padding ( [ . bottom] , 200 )
4141
42- BiometricToggleView ( isEnabled: $useBiometricID) {
43- showPasswordAuthenticationView = true
42+ BiometricToggleView ( isEnabled: $useBiometricID) { status in
43+ if status {
44+ showPasswordAuthenticationView = true
45+ } else {
46+ SessionManager . shared. logout ( environment: APIConfiguration . shared. environment, clearBiometricCreds: true )
47+ }
4448 }
4549 . padding ( [ . bottom] , 30 )
4650
@@ -95,10 +99,6 @@ struct UserProfileView: View {
9599 Button {
96100 Utilities . clearAllData ( )
97101
98- if useBiometricID == false {
99- SessionManager . shared. logout ( environment: APIConfiguration . shared. environment, clearBiometricCreds: true )
100- }
101-
102102 if let window = UIApplication . window ( ) {
103103 window. rootViewController = UIHostingController ( rootView: PosmLoginView ( ) )
104104 }
You can’t perform that action at this time.
0 commit comments