mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-02 11:49:10 +00:00
fix: Only a System Manager can register as a seller
- every other user has read only access
This commit is contained in:
@@ -162,14 +162,23 @@ def load_base64_image_from_items(items):
|
|||||||
|
|
||||||
|
|
||||||
def get_hub_connection():
|
def get_hub_connection():
|
||||||
|
read_only = True
|
||||||
|
|
||||||
if frappe.db.exists('Data Migration Connector', 'Hub Connector'):
|
if frappe.db.exists('Data Migration Connector', 'Hub Connector'):
|
||||||
hub_connector = frappe.get_doc('Data Migration Connector', 'Hub Connector')
|
hub_connector = frappe.get_doc('Data Migration Connector', 'Hub Connector')
|
||||||
hub_connection = hub_connector.get_connection()
|
|
||||||
return hub_connection.connection
|
# full rights to user who registered as hub_seller
|
||||||
|
if hub_connector.username == frappe.session.user:
|
||||||
|
read_only = False
|
||||||
|
|
||||||
|
if not read_only:
|
||||||
|
hub_connection = hub_connector.get_connection()
|
||||||
|
return hub_connection.connection
|
||||||
|
|
||||||
# read-only connection
|
# read-only connection
|
||||||
hub_connection = FrappeClient(frappe.conf.hub_url)
|
if read_only:
|
||||||
return hub_connection
|
hub_connection = FrappeClient(frappe.conf.hub_url)
|
||||||
|
return hub_connection
|
||||||
|
|
||||||
|
|
||||||
def get_field_mappings():
|
def get_field_mappings():
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ class HubSettings(Document):
|
|||||||
def register(self):
|
def register(self):
|
||||||
""" Create a User on hub.erpnext.org and return username/password """
|
""" Create a User on hub.erpnext.org and return username/password """
|
||||||
|
|
||||||
|
if 'System Manager' not in frappe.get_roles():
|
||||||
|
frappe.throw(_('Only users with System Manager role can register on Marketplace'), frappe.PermissionError)
|
||||||
|
|
||||||
# TODO: site_name for cloud sites
|
# TODO: site_name for cloud sites
|
||||||
protocol = 'http://'
|
protocol = 'http://'
|
||||||
self.site_name = protocol + frappe.local.site + ':' + str(frappe.conf.webserver_port)
|
self.site_name = protocol + frappe.local.site + ':' + str(frappe.conf.webserver_port)
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ erpnext.hub.Marketplace = class Marketplace {
|
|||||||
this.make_body();
|
this.make_body();
|
||||||
this.setup_events();
|
this.setup_events();
|
||||||
this.refresh();
|
this.refresh();
|
||||||
if (!is_registered) {
|
if (!is_registered && frappe.user_roles.includes('System Manager')) {
|
||||||
this.page.set_primary_action('Become A Seller', this.show_register_dialog.bind(this))
|
this.page.set_primary_action('Become a Seller', this.show_register_dialog.bind(this))
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user