We have a customer service department that will occasionally need to create a user account and enters orders that are placed via phone. These customer service users are in a custom role that is ACL's to only allow access to orders and customer management. Right now they must be granted the ability to manage customer roles since they have to manually add the user to the 'Registered' or 'Guest' role. This also allows them the ability to self promote or accidentally make a customer a global admin(or remove a legit admin). Anyone know of a way to either prohibit global admin access while maintaining the ability to add the 'registered' role or automatically add the 'registered' role to a new customer account thats been created by an admin?
But you can hack the Presentation\Nop.Web\Administration\Views\Customer\Create.cshtml view and add the Registered role id to the CustomerModel before calling the _CreateOrUpdate partial view.
List<int> selectedCustomerRoleIds = new List<int>(Model.SelectedCustomerRoleIds); selectedCustomerRoleIds.Add(3);
Alternatively you can do this via a plugin and an ActionFilter, which is the proper way to do it. But it might be too much for such a simple requirement.
I'm testing an upgrade from 3.3 to 3.6 and this is no longer working. When I make the code change now I get the following error. Any ideas on what has changed? The only difference I notice is @Html.AntiForgeryToken() in the 3.6 Create.cshtml code (was not in the 3.3 code).
Server Error in '/' Application. --------------------------------------------------------------------------------
Value cannot be null. Parameter name: collection Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentNullException: Value cannot be null. Parameter name: collection
Source Error:
Line 17: </div> Line 18: </div> Line 19: List<int> selectedCustomerRoleIds = new List<int>(Model.SelectedCustomerRoleIds); Line 20: selectedCustomerRoleIds.Add(3); Line 21:
I think you can change line 19 to just this because if Create, Model.SelectedCustomerRoleIds is always null
List<int> selectedCustomerRoleIds = new List<int>();
but if you want to be safe use this
List<int> selectedCustomerRoleIds; if (Model.SelectedCustomerRoleIds == null) selectedCustomerRoleIds = new List<int>(); else selectedCustomerRoleIds = new List<int>(Model.SelectedCustomerRoleIds);