fix(email): oauth_access call and info message
This commit is contained in:
parent
f79185d79c
commit
a4e5df674b
1 changed files with 42 additions and 44 deletions
|
|
@ -67,22 +67,16 @@ frappe.email_defaults_pop = {
|
|||
};
|
||||
|
||||
function oauth_access(frm) {
|
||||
return frappe.call({
|
||||
method: "frappe.client.get",
|
||||
args: {
|
||||
doctype: "Connected App",
|
||||
name: frm.doc.connected_app,
|
||||
},
|
||||
callback: app => {
|
||||
return frappe.call({
|
||||
method: "initiate_web_application_flow",
|
||||
doc: app.message,
|
||||
callback: function (r) {
|
||||
window.open(r.message, "_self");
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
frappe.model.with_doc("Connected App", frm.doc.connected_app, () => {
|
||||
const connected_app = frappe.get_doc("Connected App", frm.doc.connected_app);
|
||||
return frappe.call({
|
||||
doc: connected_app,
|
||||
method: "initiate_web_application_flow",
|
||||
callback: function(r) {
|
||||
window.open(r.message, "_self");
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
function set_default_max_attachment_size(frm, field) {
|
||||
|
|
@ -176,18 +170,20 @@ frappe.ui.form.on("Email Account", {
|
|||
},
|
||||
|
||||
after_save(frm) {
|
||||
frappe.call({
|
||||
method: "frappe.integrations.doctype.connected_app.connected_app.check_active_token",
|
||||
args: {
|
||||
connected_app: frm.doc.connected_app,
|
||||
connected_user: frm.doc.connected_user,
|
||||
},
|
||||
callback: r => {
|
||||
if (!r.message) {
|
||||
oauth_access(frm);
|
||||
}
|
||||
},
|
||||
});
|
||||
if (frm.doc.auth_method === "OAuth") {
|
||||
frappe.call({
|
||||
method: "frappe.integrations.doctype.connected_app.connected_app.check_active_token",
|
||||
args: {
|
||||
connected_app: frm.doc.connected_app,
|
||||
connected_user: frm.doc.connected_user,
|
||||
},
|
||||
callback: r => {
|
||||
if (!r.message) {
|
||||
oauth_access(frm);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
show_gmail_message_for_less_secure_apps: function (frm) {
|
||||
|
|
@ -203,22 +199,24 @@ frappe.ui.form.on("Email Account", {
|
|||
},
|
||||
|
||||
show_oauth_authorization_message(frm) {
|
||||
frappe.call({
|
||||
method: "frappe.integrations.doctype.connected_app.connected_app.check_active_token",
|
||||
args: {
|
||||
connected_app: frm.doc.connected_app,
|
||||
connected_user: frm.doc.connected_user,
|
||||
},
|
||||
callback: r => {
|
||||
if (frm.doc.auth_method === "OAuth" && !r.message) {
|
||||
let msg = __(
|
||||
'OAuth has been enabled but not authorised. Please use "Authorise API Access" button to do the same.'
|
||||
);
|
||||
frm.dashboard.clear_headline();
|
||||
frm.dashboard.set_headline_alert(msg, "yellow");
|
||||
}
|
||||
},
|
||||
});
|
||||
if (frm.doc.auth_method === "OAuth") {
|
||||
frappe.call({
|
||||
method: "frappe.integrations.doctype.connected_app.connected_app.check_active_token",
|
||||
args: {
|
||||
connected_app: frm.doc.connected_app,
|
||||
connected_user: frm.doc.connected_user,
|
||||
},
|
||||
callback: r => {
|
||||
if (!r.message) {
|
||||
let msg = __(
|
||||
'OAuth has been enabled but not authorised. Please use "Authorise API Access" button to do the same.'
|
||||
);
|
||||
frm.dashboard.clear_headline();
|
||||
frm.dashboard.set_headline_alert(msg, "yellow");
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
authorize_api_access: function (frm) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue