chore(patch): disable all email accounts with oauth mechanism

This commit is contained in:
phot0n 2023-01-15 21:01:03 +05:30
parent 88d4d5e10d
commit b5c81cc015
3 changed files with 17 additions and 1 deletions

View file

@ -911,7 +911,7 @@ def remove_user_email_inbox(email_account):
@frappe.whitelist()
def set_email_password(email_account, password):
account = frappe.get_doc("Email Account", email_account)
if account.awaiting_password and not account.auth_method == "OAuth":
if account.awaiting_password and account.auth_method != "OAuth":
account.awaiting_password = 0
account.password = password
try:

View file

@ -198,6 +198,7 @@ frappe.patches.v14_0.delete_payment_gateways
frappe.patches.v15_0.remove_event_streaming
frappe.patches.v15_0.remove_prepared_report_settings_from_system_settings
frappe.patches.v15_0.copy_disable_prepared_report_to_prepared_report
frappe.patches.v14_0.disable_email_accounts_with_oauth
[post_model_sync]
frappe.patches.v14_0.drop_data_import_legacy

View file

@ -0,0 +1,15 @@
import click
import frappe
def execute():
# Setting awaiting password to 1 for email accounts where Oauth is enabled.
# This is done so that people can resetup their email accounts with connected app mechanism.
doctype = frappe.qb.DocType("Email Account")
frappe.qb.update(doctype).set(doctype.awaiting_password, 1).where(doctype.auth_mehtod == "OAuth")
click.secho(
"Email Accounts with auth method as OAuth have been disabled."
"Please re-setup your OAuth based email accounts with the connected app mechanism to re-enable them."
)