Is there a way to add some additonal params into t...
# support-questions
p
Is there a way to add some additonal params into the passwordless signiniup endpoint and then include those in the magic link url that gets sent back to the user?
r
Hey @PitchAsh
Absolutely.
So when the link is created, there is a unique preAuthSessionId that’s generated for the “login attempt”. You can save info in your db against that id. The same ID is available to you when the consume code / magic link api is called. So you can fetch the info using that ID
p
Actually.. what I need todo is have the frontend pass some meta data related to branding.. like a tenent.id when calling auth/signinup/code.. I then need to unclude that tenent.id in the magic link url so that if a user clicks the link from the email the frontend can then display the correct branding..
r
Hmm. So that’s possible as well
Since you have to send the link email yourself anyway, you can modify the link however you like (for example by adding a relevant query param to it)
And then have the frontend read the link’s query param to show the right branding
p
sure.. i can modify the link... how does the frontend pass extra params on the auth/signinup/code api call?
r
There are pre API hooks we have which alllw you to modify the request being sent
p
trying to find the docs..
r
Give me a moment
So you wanna modify the create_code and resend_code request
Finally, on the backend, you will have to override the create code api, read the custom attribute from the input body, and set it in the userContext object (before calling the original implementation)
The modified userContext object will then be available in the function to send the email - in which you can modify the link
p
yes ok think i have it
p
perfect thanks
Sorry one more question.. once I get the frontend hook to override the api call.. I can add additional params along with the email in the request body... which backend function / method would I need to override to extract this and ensure its added to the context?
r
In passwordless.init > override > apis > createCodePOST and resendCodePOST
p
ok.. i could get it from the options.req.body I think
r
Await Options.req.getJSONBody() (I think that’s the name of the function).
p
cool
2 Views