From 5d949d4c0fab93fecaf18f0106906776d2224c0b Mon Sep 17 00:00:00 2001 From: Erica Z Date: Fri, 1 Nov 2024 20:51:27 +0100 Subject: [PATCH] fix double password storage --- src/ui/setup.vala | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/ui/setup.vala b/src/ui/setup.vala index 9a0f776..0ddca62 100644 --- a/src/ui/setup.vala +++ b/src/ui/setup.vala @@ -117,16 +117,26 @@ public class Audrey.Ui.Setup : Adw.PreferencesDialog { }); } - public void save () { + private async void save_internal () { this.authn_can_edit = false; - Secret.password_store.begin (secret_schema, null, "Audrey Subsonic password", this.password, null, (obj, res) => { - try { - Secret.password_store.end (res); - } catch (Error e) { - error ("could not store password in keyring: %s", e.message); - } - this.authn_can_edit = true; - }, "server-url", this.server_url, "username", this.username); + + try { + yield Secret.password_clear (secret_schema, null); + } catch (Error e) { + error ("could not clear previous passwords from keyring: %s", e.message); + } + + try { + yield Secret.password_store (secret_schema, null, "Audrey Subsonic password", this.password, null, "server-url", this.server_url, "username", this.username); + } catch (Error e) { + error ("could not store password in keyring: %s", e.message); + } + + this.authn_can_edit = true; + } + + public void save () { + this.save_internal.begin (); } ~Setup () {