[FIX] microsoft_outlook,google_gmail: require username for OAuth2
Current behavior: Connections for outgoing email servers using Outlook/Office365 or Gmail accounts will establish an OAuth2 authentication for the smtp server. Through the `ir_mail_server` form view, one can fetch the necessary tokens by logging in into their Microsoft/Gmail account. Not specifying an username (`smtp_user`) on the `ir_mail_server` record will not produce an error while fetching those tokens. But when trying to test the connection or use that server to send an email, even if the FROM header is correctly set (i.e. the account email address authorized to sent emails), the smtp connection will fail. This is due to the fact that when `smtp_user == False`, the respective method `_generate_outlook_oauth2_string` or respectively `_generate_oauth2_string` will not be called and send the necessary OAuth2 string when sending an email through the smtp connection. This will lead to a `5.7.57 Client not authenticated to send mail.` error. After this change: Add specific UserErrors that get called if `smpt_user == False` before the actions in `open_google_gmail_uri` and `open_microsoft_outlook_uri` get called. This forces the user to input a `smpt_user` (field Username) before the login page for OAuth2 gets called to fetch the tokens. Note: there is no check if the user inputs the right username, only that the field is not empty. So it is still possible to input an invalid username. opw-3268246 closes odoo/odoo#121526 X-original-commit: 0f6602c7 Signed-off-by:Stéphane Debauche (std) <std@odoo.com> Signed-off-by:
jorv-odoo <jorv@odoo.com>
Showing
- addons/google_gmail/i18n/google_gmail.pot 9 additions, 0 deletionsaddons/google_gmail/i18n/google_gmail.pot
- addons/google_gmail/models/google_gmail_mixin.py 5 additions, 0 deletionsaddons/google_gmail/models/google_gmail_mixin.py
- addons/microsoft_outlook/i18n/microsoft_outlook.pot 9 additions, 0 deletionsaddons/microsoft_outlook/i18n/microsoft_outlook.pot
- addons/microsoft_outlook/models/microsoft_outlook_mixin.py 5 additions, 0 deletionsaddons/microsoft_outlook/models/microsoft_outlook_mixin.py
Loading
Please register or sign in to comment