Commit 5bc5f255 authored by Michael Gratton's avatar Michael Gratton 🤞

Merge branch 'wip/fix-not-prompting-for-missing-password' into 'master'

Fix GOA accounts losing their credentials when updated

Closes #250

See merge request !129

(cherry picked from commit c0c0856d)

e286e9de Throw errors when IMAP or SMTP services have incomplete creds
81bc2e5f Make GoaMediator::prompt_token a no-op
938baa0a Ensure GOA accounts have their creds updated after the account itself is
5e6e4f2e Tidy up and add some debug logging to GOA signal hadlers
parent 56ec2281
Pipeline #62146 failed with stages
in 60 minutes
......@@ -828,6 +828,31 @@ public class Accounts.Manager : GLib.Object {
}
}
private async void update_goa_account(Geary.AccountInformation account,
GLib.Cancellable? cancellable) {
GoaMediator mediator = (GoaMediator) account.mediator;
try {
yield mediator.update(account, cancellable);
// Update will clear the creds, so make sure they get
// refreshed
yield account.load_outgoing_credentials(cancellable);
yield account.load_incoming_credentials(cancellable);
} catch (GLib.Error err) {
report_problem(
new Geary.AccountProblemReport(
Geary.ProblemType.GENERIC_ERROR,
account,
err
));
}
// XXX need to notify the engine that creds may have changed
set_available(account, mediator.is_available);
}
private async void open_goa_settings(string action,
string? param,
GLib.Cancellable? cancellable)
......@@ -882,37 +907,20 @@ public class Accounts.Manager : GLib.Object {
}
private void on_goa_account_added(Goa.Object account) {
debug("GOA account added: %s", account.get_account().id);
// XXX get a cancellable for this.
this.create_goa_account.begin(account, null);
}
private void on_goa_account_changed(Goa.Object account) {
string id = to_geary_id(account);
AccountState? state = this.accounts.get(id);
debug("GOA account changed: %s", account.get_account().id);
AccountState? state = this.accounts.get(to_geary_id(account));
// XXX get a cancellable to these
if (state != null) {
// We already know about this account, so check that it is
// still valid. If not, the account should be disabled,
// not deleted, since it may be re-enabled at some point.
GoaMediator mediator = (GoaMediator) state.account.mediator;
mediator.update.begin(
state.account,
null, // XXX Get a cancellable to this somehow
(obj, res) => {
try {
mediator.update.end(res);
} catch (GLib.Error err) {
report_problem(
new Geary.AccountProblemReport(
Geary.ProblemType.GENERIC_ERROR,
state.account,
err
));
}
set_available(state.account, mediator.is_available);
}
);
this.update_goa_account.begin(state.account, null);
} else {
// We haven't created an account for this GOA account
// before, so try doing so now.
......@@ -923,11 +931,11 @@ public class Accounts.Manager : GLib.Object {
}
private void on_goa_account_removed(Goa.Object account) {
AccountState? state = this.accounts.get(
to_geary_id(account)
);
debug("GOA account removed: %s", account.get_account().id);
AccountState? state = this.accounts.get(to_geary_id(account));
if (state != null) {
// Just disabled it for now in case the GOA daemon as just
// shutting down.
set_available(state.account, false);
}
}
......
......@@ -107,15 +107,10 @@ public class GoaMediator : Geary.CredentialsMediator, Object {
Geary.ServiceInformation service,
GLib.Cancellable? cancellable)
throws GLib.Error {
// Prompt GOA to update the creds. This might involve some
// user interaction.
yield update(account, cancellable);
// XXX now open a dialog that says "Click here to change your
// GOA password" or "GOA credentials need renewing" or
// XXX Open a dialog that says "Click here to change your GOA
// password" or "GOA credentials need renewing" or
// something. Connect to the GOA service and wait until we
// hear that needs attention is no longer true.
return this.is_available;
}
......
......@@ -387,16 +387,14 @@ internal class Geary.Imap.ClientService : Geary.ClientService {
debug("[%s] Opening new session", this.account.id);
Credentials? login = this.configuration.credentials;
if (login != null && !login.is_complete()) {
notify_authentication_failed();
throw new ImapError.UNAUTHENTICATED("Token not loaded");
}
ClientSession new_session = new ClientSession(remote);
yield new_session.connect_async(cancellable);
try {
yield new_session.initiate_session_async(
this.configuration.credentials, cancellable
);
yield new_session.initiate_session_async(login, cancellable);
} catch (Error err) {
// need to disconnect before throwing error ... don't
// honor Cancellable here, it's important to disconnect
......
......@@ -238,7 +238,7 @@ internal class Geary.Smtp.ClientService : Geary.ClientService {
throws Error {
Credentials? login = this.account.get_outgoing_credentials();
if (login != null && !login.is_complete()) {
notify_authentication_failed();
throw new SmtpError.AUTHENTICATION_FAILED("Token not loaded");
}
Smtp.ClientSession smtp = new Geary.Smtp.ClientSession(this.remote);
......
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