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 () {