From c81eb419d44ec141956f6132c2f61723641c490d Mon Sep 17 00:00:00 2001 From: Pedro Augusto da Silva Soares Date: Tue, 16 Apr 2024 22:57:38 -0300 Subject: [PATCH] Clear credentials state and delete keychain on SignOut request (#10558) Release Notes: - Fixed ([#4716](https://github.com/zed-industries/zed/issues/4716)). --------- Co-authored-by: Conrad Irwin --- crates/client/src/client.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/client/src/client.rs b/crates/client/src/client.rs index db88afb03847ec83fb0513a2f14dd90fe6b5bf5b..7d18e5d2db9b07e85bdb9d79a53ca5fe37c25162 100644 --- a/crates/client/src/client.rs +++ b/crates/client/src/client.rs @@ -132,7 +132,7 @@ pub fn init(client: &Arc, cx: &mut AppContext) { move |_: &SignOut, cx| { if let Some(client) = client.upgrade() { cx.spawn(|cx| async move { - client.disconnect(&cx); + client.sign_out(&cx).await; }) .detach(); } @@ -1250,6 +1250,15 @@ impl Client { }) } + pub async fn sign_out(self: &Arc, cx: &AsyncAppContext) { + self.state.write().credentials = None; + self.disconnect(&cx); + + if self.has_keychain_credentials(cx).await { + delete_credentials_from_keychain(cx).await.log_err(); + } + } + pub fn disconnect(self: &Arc, cx: &AsyncAppContext) { self.peer.teardown(); self.set_status(Status::SignedOut, cx);