NicolasAlt
08/18/2022, 3:44 PMrp_st
08/18/2022, 3:44 PMNicolasAlt
08/18/2022, 3:51 PMrp_st
08/18/2022, 3:56 PMpreAuthSessionId
. You want to save the preAuthSessionId
on the CLI and query an API that checks if the preAuthSessionId
has been consumed or not.
- When the user clicks on the displayed magic link, it would open the browser.
- Then, on that page, you would check if a session already exists (using our frontend SDK). If it does, you want to call an API giving it the one time use token + the preAuthSessionId
. In the API, you can do session verification to get the userID and consume the one time use token (using our backend SDK). If the one time use token was consumed successfully, you want to map the preAuthSessionId
to the userID in your own db.
- If the user is not logged in, you can store the one time use token + preAuthSessionId
in localstorage and ask them to login. Post login, you would do as per the previous step.
- Finally, the API that the CLI is calling would eventually see that there is a userID mapped to the preAuthSessionId
, which it could return to the CLI.
One catch here is that to generate the magic link in the first place, you would need to provide an email to the backend SDK function. You can give it a random / unique email and then delete this user once the magic link code is consumed.rp_st
08/18/2022, 3:57 PMrp_st
08/18/2022, 4:00 PMNicolasAlt
08/18/2022, 4:02 PMrp_st
08/18/2022, 4:05 PMpreAuthSessionId
to the userID.
You could store that mapping with supertokens itself using the user metadata recipe which allows you to map any ID with any JSON. So you could store preAuthSessionId => {"userID": "..."}
mapping with supertokens and later get that value.rp_st
08/18/2022, 4:06 PMNicolasAlt
08/18/2022, 4:07 PMNicolasAlt
08/18/2022, 4:07 PMNicolasAlt
08/18/2022, 4:07 PMrp_st
08/18/2022, 4:09 PMNicolasAlt
08/18/2022, 4:11 PMrp_st
08/18/2022, 4:11 PMrp_st
08/19/2022, 1:15 PMrp_st
08/20/2022, 6:27 AMrp_st
08/20/2022, 6:27 AMNicolasAlt
08/22/2022, 9:22 AMrp_st
08/22/2022, 9:23 AMaprilis97
12/14/2022, 12:07 PMrp_st
12/14/2022, 12:12 PM