File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -180,6 +180,7 @@ class AppState: ObservableObject {
180180 let username = Current . defaults. string ( forKey: " username " ) {
181181 // remove any keychain password if we fail to log with an invalid username or password so it doesn't try again.
182182 try ? Current . keychain. remove ( username)
183+ Current . defaults. removeObject ( forKey: " username " )
183184 }
184185
185186 Logger . appState. error ( " Authentication error: \( error. legibleDescription) " )
Original file line number Diff line number Diff line change @@ -13,8 +13,13 @@ struct GeneralPreferencePane: View {
1313 Preferences . Container ( contentWidth: 400.0 ) {
1414 Preferences . Section ( title: " Apple ID " ) {
1515 VStack ( alignment: . leading) {
16- if appState. authenticationState == . authenticated {
17- Text ( Current . defaults. string ( forKey: " username " ) ?? " - " )
16+ // If we have saved a username then we will show it here,
17+ // even if we don't have a valid session right now,
18+ // because we should be able to get a valid session if needed with the password in the keychain
19+ // and a 2FA code from the user.
20+ // Note that AppState.authenticationState is not necessarily .authenticated in this case, though.
21+ if let username = Current . defaults. string ( forKey: " username " ) {
22+ Text ( username)
1823 Button ( " Sign Out " , action: appState. signOut)
1924 } else {
2025 Button ( " Sign In " , action: { self . appState. presentingSignInAlert = true } )
You can’t perform that action at this time.
0 commit comments