Public registration - is it possible to select a role during registration?

Hello!

Is there any way for a new user to select a role during registration? Why is this necessary? For example, if there is a service portal, there are Customers and Contractors, and each needs to select how they position themselves on the portal. Therefore, during registration, the user must select a role.

Currently, I have not found such an option; any new user immediately acquires the role of “Member” upon registration, which is assigned by default in the settings.


The administrator then has to manually change the role to the desired one. But this raises two problems:

  1. If there are a lot of registrations, the administrator simply won’t have time to quickly change the new participant’s role to the desired one.
  2. How will the administrator know what role to assign to a new user who has registered with the “Member” role? There are no notifications or options where there would at least be a message for the administrator such as “I want to be a Customer” or “I want to be a Contractor.” Or then you would have to communicate with the potential Portal member in advance through external communication channels to understand what role to assign them. This is inconvenient and inefficient…

It would be convenient if the user could choose the role themselves during registration and immediately inherit all the access rights that are configured in the system… Or maybe it is possible to generate a URL link with the necessary Role parameter so that when the user clicks on the link, they register with the desired role?

Hello, please refer to:
https://docs.nocobase.com/handbook/auth/user#sign-up-form-settings

Yes, I have reviewed this documentation, but the settings only include specific (preset) fields. I am unable to add the Role field to the list of fields displayed in the registration form…


Although this field is included in the Users collection

Maybe I’m not looking carefully enough? Please tell me how to include the Role field in the registration form, if possible (without modifying the source code, of course).

You can add business fields for filling in information on the registration form. Based on the specific content of the business fields, the data can be processed manually in batches or automatically processed by the workflow.

1 Like

Thank you for your suggestion. Yes, I understand what needs to be done. In short, I need to add a “duplicate” field - Roles - and display it in the registration form. Then, depending on the value selected in this duplicate field, I need to create a workflow that, depending on one of the values, will update the User record and set the required value in the Roles associative field (if I understand correctly).

This is a “replacement” for the existing Role field (associated with the Role collection), which cannot be displayed in the registration form (I don’t know why this is, probably for security reasons, since an unregistered user cannot see the list of records in the Role collection).

I tried to create such a business process, but something is not working for me in the second node, where I need to update the Role field.

So:

  1. In the Users Collection, I created a new Select Role field, where I selected two options: Customer and Contractor.
  2. I displayed this field in the registration form
  3. I created a workflow, the essence of which is that after creating a User record (from the registration form), this record should be updated, where the Role field (associative) is filled in according to the condition (if the Select Role field = Customer, then the Role field = Customer, and similarly for the Contractor value).


For testing purposes, I have only created one node for updating - for the Customer.
4. I registered a test user with the Customer value selected, the record was created, but the process did not work completely (the second node displayed “0” as a result of debugging, while the first trigger node read everything correctly and displayed the array result).

  1. When creating a User record, the value in the Select Role field is correct (Customer), it was saved in the database. But the value in the Role field (Member) did not change to the required one, according to the workflow.

I am new to the settings of this platform. Please tell me where I made a mistake in the workflow settings, or what I did not do, why the Member value did not change to the Customer value?

@hongboji, I ran several tests, created several workflows, and noticed that in the Update Record node, the field with the Associative type (link to the Roles collection) is not updated if a many-to-many relationship is set there (i.e., if multiple values are to be selected). If the relationship is many-to-one (selection of a single value), then the update is performed successfully in such a field (the specified value appears in the field).

I created two fields in the Users collection for testing: Role and Roles Many (single and multiple relationships, respectively). Both fields are associated with the Roles collection.

I created a test workflow with a trigger to create a record in the Users collection and a node to update the fields mentioned above.

After creating a new record (Users), the specified value appears in the Role field, and the Roles Many field is empty.

Can you tell me why this is happening? Did I configure something incorrectly, or could it be a bug?

Thank you for reporting the issue. Please wait while we fix it.

1 Like

Please help me with another question: I selected the Allow Roles Union option, and then changed it back to Independent Roles.


But when creating a new user (or editing an existing one), I can still select multiple roles for them in the Roles field. Is this how it should be?

With allow roles union disabled it is still possible for a user to have multiple roles. However, when using the app they can only use permissions from 1 specific role at a time. So for example, if a user has roles sales and finance, they can either see the sales data (when using their sales role) or the finance data (when selecting their finance role), but not both at the same time. If you would now enable roles union, the user could choose “full permissions” to see both finance and sales data at the same time.

1 Like

Yes, now I understand this functionality. Thank you for explaining it with a specific example!
Then the above-mentioned problem of updating a multiple-choice field needs to be solved. Because the Roles field in the Users collection, if I understand correctly, is a multiple-choice field. I thought I could get around the problem by making (as I hoped) a single choice of value in the Roles field. But now I understand that this is impossible due to the built-in functionality.

Although, what’s stopping me from creating my own Roles collection, connecting it to Users, and using it instead of the integrated Roles collection? :wink: I think this is possible on such a powerful and cool platform as NocoBase! There, you can also configure similar conditional access logic according to the assigned values of any associative field!

But I still really want to use all the built-in features of the platform to their fullest potential, so I’ll wait for the fixed version! Especially since the Roles collection has built-in additional settings that would be difficult to recreate manually!

I’ve confirmed the issue; you should update using the “one by one” method.

1 Like

Yes, it works! Thank you for your tip. If this option works, maybe it should be mentioned in the documentation (for example, in a highlighted tip)? This would make it clear what to do in such cases and which update mode (one by one) to choose for updating a multiple-choice field.