mirror of
https://github.com/XcodesOrg/XcodesApp.git
synced 2026-03-25 08:55:46 +00:00
Merge pull request #87 from RobotsAndPencils/auth-pref-ui-change
Show stored username in General preference pane even when we don't have a valid session
This commit is contained in:
commit
352816f64a
2 changed files with 8 additions and 2 deletions
|
|
@ -180,6 +180,7 @@ class AppState: ObservableObject {
|
|||
let username = Current.defaults.string(forKey: "username") {
|
||||
// remove any keychain password if we fail to log with an invalid username or password so it doesn't try again.
|
||||
try? Current.keychain.remove(username)
|
||||
Current.defaults.removeObject(forKey: "username")
|
||||
}
|
||||
|
||||
Logger.appState.error("Authentication error: \(error.legibleDescription)")
|
||||
|
|
|
|||
|
|
@ -13,8 +13,13 @@ struct GeneralPreferencePane: View {
|
|||
Preferences.Container(contentWidth: 400.0) {
|
||||
Preferences.Section(title: "Apple ID") {
|
||||
VStack(alignment: .leading) {
|
||||
if appState.authenticationState == .authenticated {
|
||||
Text(Current.defaults.string(forKey: "username") ?? "-")
|
||||
// If we have saved a username then we will show it here,
|
||||
// even if we don't have a valid session right now,
|
||||
// because we should be able to get a valid session if needed with the password in the keychain
|
||||
// and a 2FA code from the user.
|
||||
// Note that AppState.authenticationState is not necessarily .authenticated in this case, though.
|
||||
if let username = Current.defaults.string(forKey: "username") {
|
||||
Text(username)
|
||||
Button("Sign Out", action: appState.signOut)
|
||||
} else {
|
||||
Button("Sign In", action: { self.appState.presentingSignInAlert = true })
|
||||
|
|
|
|||
Loading…
Reference in a new issue