Is there a mechanism to attach a role to a user th...
# support-questions-legacy
v
Is there a mechanism to attach a role to a user that hasn't yet signed up in Supertokens?
r
hey @vishjain.
you can pass any unique ID to the user roles function and it will attach those roles to that ID
even if that ID does not exist in supertokens as a user
v
Cool, I wanted the ability for creation of new users (emails) + roles in the supertokens database preferably but not physically create the user everywhere until the sign up is complete.
r
I see.
You would still need some unique ID to attach a role
v
When the user actually signs up, I can avoid having a new id created for that user, right? Just want to make sure I'm not scrambling up any id's here.
r
supertokens will create an ID for that user, but then you can use the useridmapping recipe to associate that new ID with the older one you had, and everything should fall in place
v
Got it, so I'll create a random id and map it to a particular role and user email. Later when the user is signing up I can do some association
r
yup
v
(sorry bit confusing, just want to make sure an admin in our dashboard only can let select people in an organization join)
r
fair enough!
feel free to ask more questions 🙂
v
Hey - quick question @rp_st on the thread here. Is storing a mapping of the randomly generated id to email possible in the user context (is that the purpose of usr context)?
Or is there another struct I can do this when attaching a role to a random role id before official sign up happens? Otherwise, I'll have to find my own way of persisting it
r
You can store the ID as cookies - would be the easiest way to handle this case i guess. And then this ID would be available during sign up request from the request cookies
v
Would prefer to store the id /cookie in the backend not in the browser, if possible, if there's some supertokens construct for me to associate made up user id with email
r
yea, you can use the user metadata feature where the ID is the email, and the JSON associated with it contains the randomly generated ID. And then on sign up, you can remove that metadata object once you create the actual user