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 {
180
180
let username = Current . defaults. string ( forKey: " username " ) {
181
181
// remove any keychain password if we fail to log with an invalid username or password so it doesn't try again.
182
182
try ? Current . keychain. remove ( username)
183
+ Current . defaults. removeObject ( forKey: " username " )
183
184
}
184
185
185
186
Logger . appState. error ( " Authentication error: \( error. legibleDescription) " )
Original file line number Diff line number Diff line change @@ -13,8 +13,13 @@ struct GeneralPreferencePane: View {
13
13
Preferences . Container ( contentWidth: 400.0 ) {
14
14
Preferences . Section ( title: " Apple ID " ) {
15
15
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)
18
23
Button ( " Sign Out " , action: appState. signOut)
19
24
} else {
20
25
Button ( " Sign In " , action: { self . appState. presentingSignInAlert = true } )
You can’t perform that action at this time.
0 commit comments