https://supertokens.com/ logo
passwordless login send custom info
n

Namratha

04/05/2023, 6:49 AM
@rp I'm using passwordless recipe, i want to send another field value say 'role' from frontend to backend while submiting the OTP. I want that value to assign roles in supertokens
r

rp

04/05/2023, 6:51 AM
You can use the pre API hook on the frontend to set the custom attribute to the consume code API, and then read that on the backend by overriding the consumeCode API
n

Namratha

04/05/2023, 11:48 AM
Passwordless.init({ contactMethod: "EMAIL_OR_PHONE", preAPIHook: async (context) => { let url = context.url; let requestInit = context.requestInit; let action = context.action; if (action === "PASSWORDLESS_CONSUME_CODE") { context.userContext= { role: "client" } } return { requestInit, url }; } }),
can i get an example for how to pass custom data from frontend pls?
this is how you can add custom props in the pre API hook