https://supertokens.com/ logo
Title
v

vishjain

11/03/2022, 5:45 PM
Is there a mechanism to attach a role to a user that hasn't yet signed up in Supertokens?
r

rp

11/03/2022, 5:45 PM
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

vishjain

11/03/2022, 5:47 PM
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

rp

11/03/2022, 5:48 PM
I see.
You would still need some unique ID to attach a role
v

vishjain

11/03/2022, 5:50 PM
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

rp

11/03/2022, 5:50 PM
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

vishjain

11/03/2022, 5:52 PM
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

rp

11/03/2022, 5:53 PM
yup
v

vishjain

11/03/2022, 5:53 PM
(sorry bit confusing, just want to make sure an admin in our dashboard only can let select people in an organization join)
r

rp

11/03/2022, 5:53 PM
fair enough!
feel free to ask more questions 🙂
v

vishjain

11/09/2022, 5:37 AM
Hey - quick question @rp 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

rp

11/09/2022, 5:43 AM
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

vishjain

11/09/2022, 5:47 AM
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

rp

11/09/2022, 5:48 AM
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