[geary/wip/rework-password-prompting: 5/5] Handle not remembering passwords properly
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/rework-password-prompting: 5/5] Handle not remembering passwords properly
- Date: Wed, 6 Mar 2019 13:01:55 +0000 (UTC)
commit dc560d1f3339f20f9c880f9cd05e3ba3625cd6e4
Author: Michael Gratton <mike vee net>
Date: Wed Mar 6 23:56:56 2019 +1100
Handle not remembering passwords properly
Ensure that when the pref for non remembering passwords is changed, that
the account's config is updated. When not rememebering the password,
clear it from the controller instead of the libsecret mediator so its
obvious what's going on, and when updating creds in the mediator return
true if a password is present, so they don't cause an immediate auth
error.
src/client/application/geary-controller.vala | 22 ++++++++++----
src/client/application/secret-mediator.vala | 43 ++++++++++++----------------
2 files changed, 36 insertions(+), 29 deletions(-)
---
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index b1a30021..94e7417a 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -773,8 +773,6 @@ public class GearyController : Geary.BaseObject {
credentials
);
if (password_dialog.run()) {
- service.remember_password = password_dialog.remember_password;
-
// The update the credentials for the service that the
// credentials actually came from
Geary.ServiceInformation creds_service =
@@ -785,14 +783,27 @@ public class GearyController : Geary.BaseObject {
password_dialog.password
);
+ // Update the remember password pref if changed
+ bool remember = password_dialog.remember_password;
+ if (creds_service.remember_password != remember) {
+ creds_service.remember_password = remember;
+ account.changed();
+ }
+
SecretMediator libsecret = (SecretMediator) account.mediator;
try {
// Update the secret using the service where the
// credentials originated, since the service forms
// part of the key's identity
- yield libsecret.update_token(
- account, creds_service, context.cancellable
- );
+ if (creds_service.remember_password) {
+ yield libsecret.update_token(
+ account, creds_service, context.cancellable
+ );
+ } else {
+ yield libsecret.clear_token(
+ account, creds_service, context.cancellable
+ );
+ }
} catch (GLib.IOError.CANCELLED err) {
// all good
} catch (GLib.Error err) {
@@ -805,6 +816,7 @@ public class GearyController : Geary.BaseObject {
)
);
}
+
context.authentication_attempts++;
} else {
// User cancelled, bail out unconditionally
diff --git a/src/client/application/secret-mediator.vala b/src/client/application/secret-mediator.vala
index 3fa56a9b..3d3645ef 100644
--- a/src/client/application/secret-mediator.vala
+++ b/src/client/application/secret-mediator.vala
@@ -46,19 +46,25 @@ public class SecretMediator : Geary.CredentialsMediator, Object {
Cancellable? cancellable)
throws GLib.Error {
bool loaded = false;
- if (service.credentials != null && service.remember_password) {
- string? password = yield Secret.password_lookupv(
- SecretMediator.schema, new_attrs(service), cancellable
- );
+ if (service.credentials != null) {
+ if (service.remember_password) {
+ string? password = yield Secret.password_lookupv(
+ SecretMediator.schema, new_attrs(service), cancellable
+ );
- if (password == null) {
- password = yield migrate_old_password(service, cancellable);
- }
+ if (password == null) {
+ password = yield migrate_old_password(service, cancellable);
+ }
- if (password != null) {
- service.credentials =
+ if (password != null) {
+ service.credentials =
service.credentials.copy_with_token(password);
- loaded = true;
+ loaded = true;
+ }
+ } else {
+ // Not remembering the password, so just make sure it
+ // has been filled in
+ loaded = service.credentials.is_complete();
}
}
@@ -68,20 +74,9 @@ public class SecretMediator : Geary.CredentialsMediator, Object {
public async void update_token(Geary.AccountInformation account,
Geary.ServiceInformation service,
Cancellable? cancellable)
- throws Error {
- if (service.credentials != null && service.remember_password) {
- try {
- yield do_store(service, service.credentials.token, cancellable);
- } catch (Error e) {
- debug(
- "Unable to store libsecret password for %s: %s %s",
- account.id,
- to_proto_value(service.protocol),
- service.credentials.user
- );
- }
- } else {
- yield clear_token(account, service, cancellable);
+ throws GLib.Error {
+ if (service.credentials != null) {
+ yield do_store(service, service.credentials.token, cancellable);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]