Linking database roles to Plasmic roles

Hi Team Plasmic! :blush:

We currently need to know how to translate the roles we have in our databases to the same roles in Plasmic. e.g Lets say a customer is registered with the role of customer in our database, how do we translate this so the user is recognized as a customer in the currentUser object?

I am grateful as always for your help!

2 Likes

Hello @aihe_team !
Can you provide more details about your current setup? Are you using Plasmic Auth?

Hi @alex_noel! I’m grateful for your response.

We are using a custom auth. Please don’t hesitate to ask if I should provide more information and what you might need. :blush:

@aihe_team I don’t know all of your limitations, but I can suggest creating exact same roles in the plasmic auth system, and to store the plasmic role ID’s in your DB Roles model.
So in theory the simplest version of your database model can be something like this:

Role {
  id, 
  plasmicRoleId,
  title
}

Then you can re-point your current reference from role.id to role.plasmicRoleId to use them from within the front-end via currentUser object.

It is impossible to copy your roles from external DB or bind them dynamically. If you want to maintain only 1 set of roles - you’d probably have to configure next-auth on the next.js instance of your application manually via code.

Would this be a solution in your case?

1 Like

@alex_noel I’m so grateful for this!

Looking into this! Please give me sometime to get back to you!

@alex_noel Can you point us to something that shows how to get the plasmicRoleId please?

I’m very grateful in advance! :blush:

2 Likes

Hi @alex_noel I found roleids.

For others who might have the same issue, roleIds are located in the plasmic user object. To get access to the plasmicUser object. See the snap shot below.

1 Like