Merge pull request #20517 from barredterra/gc-perms
fix: role perms on Google Contacts
This commit is contained in:
commit
f95a042756
4 changed files with 22 additions and 14 deletions
|
|
@ -111,6 +111,7 @@ def authorize_access(g_calendar, reauthorize=None):
|
|||
"""
|
||||
google_settings = frappe.get_doc("Google Settings")
|
||||
google_calendar = frappe.get_doc("Google Calendar", g_calendar)
|
||||
google_calendar.check_permission("write")
|
||||
|
||||
redirect_uri = (
|
||||
get_request_site_address(True)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"actions": [],
|
||||
"autoname": "format:GC-{email_id}",
|
||||
"creation": "2019-06-14 00:09:39.441961",
|
||||
"doctype": "DocType",
|
||||
|
|
@ -97,10 +98,12 @@
|
|||
"label": "Push to Google Contacts"
|
||||
}
|
||||
],
|
||||
"modified": "2020-09-18 17:26:09.703215",
|
||||
"links": [],
|
||||
"modified": "2023-03-30 11:25:48.832384",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Integrations",
|
||||
"name": "Google Contacts",
|
||||
"naming_rule": "Expression",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
|
|
@ -116,17 +119,14 @@
|
|||
{
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"if_owner": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "All",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
}
|
||||
],
|
||||
"sort_field": "modified",
|
||||
"sort_order": "ASC",
|
||||
"states": [],
|
||||
"track_changes": 1
|
||||
}
|
||||
|
|
@ -36,10 +36,10 @@ def authorize_access(g_contact, reauthorize=False, code=None):
|
|||
If no Authorization code get it from Google and then request for Refresh Token.
|
||||
Google Contact Name is set to flags to set_value after Authorization Code is obtained.
|
||||
"""
|
||||
contact = frappe.get_doc("Google Contacts", g_contact)
|
||||
contact.check_permission("write")
|
||||
|
||||
oauth_code = (
|
||||
frappe.db.get_value("Google Contacts", g_contact, "authorization_code") if not code else code
|
||||
)
|
||||
oauth_code = code or contact.get_password("authorization_code")
|
||||
oauth_obj = GoogleOAuth("contacts")
|
||||
|
||||
if not oauth_code or reauthorize:
|
||||
|
|
@ -51,11 +51,9 @@ def authorize_access(g_contact, reauthorize=False, code=None):
|
|||
)
|
||||
|
||||
r = oauth_obj.authorize(oauth_code)
|
||||
frappe.db.set_value(
|
||||
"Google Contacts",
|
||||
g_contact,
|
||||
{"authorization_code": oauth_code, "refresh_token": r.get("refresh_token")},
|
||||
)
|
||||
contact.authorization_code = oauth_code
|
||||
contact.refresh_token = r.get("refresh_token")
|
||||
contact.save()
|
||||
|
||||
|
||||
def get_google_contacts_object(g_contact):
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
# Copyright (c) 2023, Frappe Technologies and Contributors
|
||||
# See license.txt
|
||||
|
||||
# import frappe
|
||||
from frappe.tests.utils import FrappeTestCase
|
||||
|
||||
|
||||
class TestGoogleContacts(FrappeTestCase):
|
||||
pass
|
||||
Loading…
Add table
Reference in a new issue