Throw errors when IMAP or SMTP services have incomplete creds

Instead of just flagging the state, it means the error gets handled
correctly at a higher level.
This commit is contained in:
Michael Gratton 2019-02-21 15:41:51 +11:00
parent c552633adb
commit e286e9dea6
2 changed files with 3 additions and 5 deletions

View file

@ -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

View file

@ -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);