User Invitation System - Saving Roles

I have an entity FirebasePendingInvites that stores an email address, token, and roles for a user to be invited and then created with. I tried to use an association attribute of the type sec$Role with a many-to-many cardinality but I realized that this creates entities in the sec$Role table which isn’t my intention because of the unique constraints.

My goal is to have a One-to-Many relationship of FirebasePendingInvites to sec$Role where a single invite is tied to multiple roles so when a user accepts an invitation link, a user is created and sequentially their user roles are created dependent on the roles that were defined during the invite process.

I am using Firebase as a custom authentication service. I believe that a user should not be created until they accept a sign-in link.

What’s the best method for storing roles for each invite?

Hi,

Having a many-to-many cardinality from FirebasePendingInvites to sec$Role does NOT lead to automatic creation of entities in the sec$Role table. It should work for you.

Alexander,

Thank you for the response. I realized that the problem is that I am trying to use Design Time Roles. When a FirebasePendingInvites entity is created the associated Roles are then inserted into sec$Role. When I create Roles during run-time I do not have the problem.

If you use design-time roles - they aren’t persisted to the database, so you cannot use many-to-many to sec$Role entity.
Design-time role is identified by its name. So you could create FirebasePendingInvites#designTimeRoleNames string attribute and store list of design-time role names as a comma-separated string.
Later when creating a user and its assigned roles - fill only UserRole#roleName field witj the name of the design-time role. Leave UserRole#role attribute empty.

Thank you very much Alexander! You have been of great help to me.

The only other question I have is whether there are any identifiers for design-time roles? I looked through RolesService and understand I can iterate through the collection of getAllRoles() using a switch statement but I would prefer to not have design-time role names hard-coded. Is there a method that returns a list of design-time role names?

Hi,
Design-time roles are identified by their name. Name should be unique and should not change in the application lifecycle. Role names are saved to the database. So you should not worry about using names.