ansont
11/23/2022, 7:52 AMnkshah2
11/23/2022, 7:53 AMansont
11/23/2022, 5:36 PMtypescript
// SignupForm.tsx
const SignupForm: React.FC = () => {
// ...
const onThirdPartySignup = async (providerId: string) => {
const authUrl = await getAuthorisationURLWithQueryParamsAndSetState({
providerId,
authorisationURL: `${process.env.NEXT_PUBLIC_APP_URL}/auth/callback/google`,
userContext: { test: 'abc', signup: true },
})
router.push(authUrl)
}
// ...
}
// frontendConfig.ts
frontendConfig = () => {
return {
appInfo,
recipeList: [
ThirdPartyEmailPasswordReact.init({
onHandleEvent: async (context) => {
console.log(JSON.stringify(context, null, 2))
},
getRedirectionURL: async (context) => {
console.log(JSON.stringify(context, null, 2))
return '/register'
},
signInAndUpFeature: {
providers: [
ThirdPartyEmailPasswordReact.Google.init(),
],
},
}),
SessionReact.init(),
],
// this is so that the SDK uses the next router for navigation
windowHandler: (oI) => {
return {
...oI,
location: {
...oI.location,
setHref: (href) => {
Router.push(href)
},
},
}
},
}
}
ansont
11/23/2022, 6:06 PMjson
{
"action": "SUCCESS",
"isNewUser": true,
"user": {
"email": "xxx@gmail.com",
"id": "2f6aad23-...",
"timeJoined": 1669185393299,
"thirdParty": {
"id": "google",
"userId": "1026..."
}
},
"userContext": {}
}
ansont
11/23/2022, 6:07 PMjson
{
"action": "SUCCESS",
"isNewUser": true
}
ansont
11/23/2022, 6:08 PMjson
{
//...
"userContext": {
"test": "abc",
"signup" true
}
}
nkshah2
11/24/2022, 5:37 AMgetRedirectionURL
isnt a social login thing, its called when the SDKs prebuilt UI needs to redirect to a page (wont be applicable since you seem to be using custom UI?). Since getAuthorisationURLWithQueryParamsAndSetState
does not trigger any redirection, the user context would not get passed.nkshah2
11/24/2022, 5:38 AMThirdPartyEmailPasswordReact.thirdPartySignInUp
which will then get passed to getRedirectionURL at some pointnkshah2
11/24/2022, 5:39 AMthirdPartySignInUp
and pass user context to itnkshah2
11/24/2022, 5:39 AMansont
11/25/2022, 9:21 PMnkshah2
11/28/2022, 5:25 AMSuperTokens is an open source authentication solution offering features like: Different types of login: Email / password, Passwordless (OTP or Magic link based).
Powered by