fix bug 4664, 'OAUTH2 overwrites passwords even for plaintext logins'

based on patch by Roland Haas
This commit is contained in:
Paul 2023-02-21 16:44:38 +00:00
parent c61593c30a
commit 48086e4e82
3 changed files with 6 additions and 1 deletions

View file

@ -344,3 +344,4 @@ contributors (in addition to the above; based on Changelog)
Frank Mueller
JP Guillonneau
Viatrix
Roland Haas

View file

@ -164,6 +164,7 @@ static char *CONTRIBS_LIST[] = {
"Mitko Haralanov",
"Alexander Lyons Harkness",
"Hashimoto",
"Roland Haas",
"Jacob Head",
"Federico Heinz",
"Geir Helland",

View file

@ -35,6 +35,7 @@
#include <string.h>
#include <errno.h>
#include "imap.h"
#include "oauth2.h"
#include "md5.h"
#include "utils.h"
@ -653,7 +654,9 @@ gint oauth2_check_passwds (PrefsAccount *ac_prefs)
if (ret)
log_message(LOG_PROTOCOL, _("OAuth2 access token not obtained\n"));
else {
passwd_store_set_account(ac_prefs->account_id, PWS_ACCOUNT_RECV, OAUTH2Data->access_token, FALSE);
if (ac_prefs->imap_auth_type == IMAP_AUTH_OAUTH2 ||
(ac_prefs->use_pop_auth && ac_prefs->pop_auth_type == POPAUTH_OAUTH2))
passwd_store_set_account(ac_prefs->account_id, PWS_ACCOUNT_RECV, OAUTH2Data->access_token, FALSE);
if (ac_prefs->use_smtp_auth && ac_prefs->smtp_auth_type == SMTPAUTH_OAUTH2)
passwd_store_set_account(ac_prefs->account_id, PWS_ACCOUNT_SEND, OAUTH2Data->access_token, FALSE);
passwd_store_set_account(ac_prefs->account_id, PWS_ACCOUNT_OAUTH2_EXPIRY, OAUTH2Data->expiry_str, FALSE);