fix(minor): only show authorization message if connected app is set (#19605)

This commit is contained in:
Ritwik Puri 2023-01-16 16:22:38 +05:30 committed by GitHub
parent 50327203ce
commit 1e6086fd75
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -166,7 +166,7 @@ frappe.ui.form.on("Email Account", {
},
show_oauth_authorization_message(frm) {
if (frm.doc.auth_method === "OAuth") {
if (frm.doc.auth_method === "OAuth" && frm.doc.connected_app) {
frappe.call({
method: "frappe.integrations.doctype.connected_app.connected_app.has_token",
args: {

View file

@ -167,4 +167,4 @@ def callback(code=None, state=None):
def has_token(connected_app, connected_user=None):
app = frappe.get_doc("Connected App", connected_app)
token_cache = app.get_token_cache(connected_user or frappe.session.user)
return bool(token_cache.get_password("access_token", False))
return bool(token_cache and token_cache.get_password("access_token", False))