productdevbook
12/14/2022, 6:55 AMts
thirdPartySignInUpPOST: async (input) => {
try {
await originalImplementation.thirdPartySignInUpPOST!(input)
}
catch (err: any) {
if (err.message === 'Cannot sign up as email already exists') {
// this error was thrown from our function override above.
// so we send a useful message to the user
return {
status: 'GENERAL_ERROR',
message: 'Seems like you already have an account with another method. Please use that instead.',
}
}
throw err
}
rp
12/14/2022, 6:56 AMsattvikc
12/14/2022, 6:58 AMproductdevbook
12/14/2022, 7:00 AMts
recipeList: [
ThirdPartyEmailPassword.init({
providers: [
Github({
clientId: env.github.appId,
clientSecret: env.github.privateKey,
}),
],
sattvikc
12/14/2022, 7:03 AMproductdevbook
12/14/2022, 7:04 AMsattvikc
12/14/2022, 7:05 AMproductdevbook
12/14/2022, 7:06 AMsattvikc
12/14/2022, 7:06 AMproductdevbook
12/14/2022, 7:07 AMsattvikc
12/14/2022, 7:09 AMproductdevbook
12/14/2022, 7:09 AMsattvikc
12/14/2022, 7:10 AMproductdevbook
12/14/2022, 7:12 AMsattvikc
12/14/2022, 7:15 AMproductdevbook
12/14/2022, 7:15 AMsattvikc
12/14/2022, 7:15 AMproductdevbook
12/14/2022, 7:15 AMsattvikc
12/14/2022, 7:16 AMproductdevbook
12/14/2022, 7:16 AMsattvikc
12/14/2022, 7:16 AMproductdevbook
12/14/2022, 7:17 AMsattvikc
12/14/2022, 7:17 AMproductdevbook
12/14/2022, 7:17 AMawait originalImplementation.thirdPartySignInUpPOST!(input)
iam delete and fixed
https://supertokens.com/docs/thirdpartyemailpassword/common-customizations/deduplication/implementing-deduplication
but your addedsattvikc
12/14/2022, 7:20 AMproductdevbook
12/14/2022, 7:22 AMrp
12/14/2022, 7:22 AMawait originalImplementation.thirdPartySignInUpPOST!(input)
. if that's not there, then it won't actually attempt to login the user at all.await originalImplementation.thirdPartySignInUpPOST!(input)
twice..productdevbook
12/14/2022, 7:23 AMrp
12/14/2022, 7:23 AMawait originalImplementation.thirdPartySignInUpPOST
just once in the overridethirdPartySignInUpPOST: async (input) => {
try {
await originalImplementation.thirdPartySignInUpPOST!(input)
if (!originalImplementation.thirdPartySignInUpPOST)
throw new Error('thirdPartySignInUpPOST is not available')
const response = await originalImplementation.thirdPartySignInUpPOST(input)
if (response.status === 'OK') {
const externalUserId = response.user.thirdParty
? `${response.user.thirdParty.id}|${response.user.thirdParty.userId}`
: null
await storage.userRepo.ensureUserExists({
superTokensUserId: response.user.id,
email: response.user.email,
externalAuthUserId: externalUserId || undefined,
})
}
return response
}
await originalImplementation.thirdPartySignInUpPOST!(input)
at the start of the funciton, and then const response = await originalImplementation.thirdPartySignInUpPOST(input)
again.productdevbook
12/14/2022, 7:24 AMts
try {
const response = await originalImplementation.thirdPartySignInUpPOST!(input)
if (!originalImplementation.thirdPartySignInUpPOST)
throw new Error('thirdPartySignInUpPOST is not available')
if (response.status === 'OK') {
const externalUserId = response.user.thirdParty
? `${response.user.thirdParty.id}|${response.user.thirdParty.userId}`
: null
await storage.userRepo.ensureUserExists({
superTokensUserId: response.user.id,
email: response.user.email,
externalAuthUserId: externalUserId || undefined,
})
}
return response
}
rp
12/14/2022, 7:24 AMtry
line?productdevbook
12/14/2022, 7:25 AMts
thirdPartySignInUpPOST: async (input) => {
try {
const response = await originalImplementation.thirdPartySignInUpPOST!(input)
if (!originalImplementation.thirdPartySignInUpPOST)
throw new Error('thirdPartySignInUpPOST is not available')
if (response.status === 'OK') {
const externalUserId = response.user.thirdParty
? `${response.user.thirdParty.id}|${response.user.thirdParty.userId}`
: null
await storage.userRepo.ensureUserExists({
superTokensUserId: response.user.id,
email: response.user.email,
externalAuthUserId: externalUserId || undefined,
})
}
return response
}
catch (err: any) {
if (err.message === 'Cannot sign up as email already exists') {
// this error was thrown from our function override above.
// so we send a useful message to the user
return {
status: 'GENERAL_ERROR',
message: 'Seems like you already have an account with another method. Please use that instead.',
}
}
throw err
}
},
rp
12/14/2022, 7:25 AMproductdevbook
12/14/2022, 7:26 AMrp
12/14/2022, 7:26 AMproductdevbook
12/14/2022, 7:27 AM