Commit a0fbf847 authored by Michael Gratton's avatar Michael Gratton 🤞

Fix some crashes prompting for passwords in the controller

Ensure the credential's token is actually updated, is updated on the
right service, and that the right credentials and service are presented
in the password dialog.
parent 30b55a03
......@@ -769,26 +769,33 @@ public class GearyController : Geary.BaseObject {
PasswordDialog password_dialog = new PasswordDialog(
this.application.get_active_window(),
account,
service
service,
credentials
);
if (password_dialog.run()) {
service.credentials = service.credentials.copy_with_token(
password_dialog.password
);
service.remember_password = password_dialog.remember_password;
// The update the credentials for the service that the
// credentials actually came from
Geary.ServiceInformation creds_service =
credentials == account.incoming.credentials
(credentials == account.incoming.credentials)
? account.incoming
: account.outgoing;
creds_service.credentials = credentials.copy_with_token(
password_dialog.password
);
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
);
// Update the actual service in the engine though
// Update the engine using the original service
// however, since that is the one waiting for the
// credentials
yield this.application.engine.update_account_service(
account, service, context.cancellable
);
......
......@@ -25,7 +25,8 @@ public class PasswordDialog {
public PasswordDialog(Gtk.Window? parent,
Geary.AccountInformation account,
Geary.ServiceInformation service) {
Geary.ServiceInformation service,
Geary.Credentials? credentials) {
Gtk.Builder builder = GioUtil.create_builder("password-dialog.glade");
dialog = (Gtk.Dialog) builder.get_object("PasswordDialog");
......@@ -43,18 +44,13 @@ public class PasswordDialog {
Gtk.Label primary_text_label = (Gtk.Label) builder.get_object("primary_text_label");
primary_text_label.set_markup(PRIMARY_TEXT_MARKUP.printf(PRIMARY_TEXT_FIRST_TRY));
bool is_smtp = service.protocol == Geary.Protocol.SMTP;
Geary.Credentials? credentials = (is_smtp)
? account.get_outgoing_credentials() : account.incoming.credentials;
if (credentials != null) {
label_username.set_text(credentials.user);
entry_password.set_text(credentials.token ?? "");
}
check_remember_password.active = service.remember_password;
if (is_smtp) {
if ((service.protocol == Geary.Protocol.SMTP)) {
label_smtp.show();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment