alen_george
12/18/2023, 10:52 AMrp_st
12/18/2023, 11:02 AMrp_st
12/18/2023, 11:02 AMalen_george
12/18/2023, 11:05 AMrp_st
12/18/2023, 11:05 AMrp_st
12/18/2023, 11:06 AMalen_george
12/18/2023, 11:07 AMrp_st
12/18/2023, 11:07 AMalen_george
12/18/2023, 11:08 AMrp_st
12/18/2023, 11:08 AMrp_st
12/18/2023, 11:08 AMrp_st
12/18/2023, 11:08 AMalen_george
12/18/2023, 11:09 AMalen_george
12/18/2023, 11:22 AMalen_george
12/19/2023, 5:43 AMrp_st
12/19/2023, 5:43 AMrp_st
12/19/2023, 5:43 AMalen_george
12/19/2023, 5:44 AMrp_st
12/19/2023, 6:02 AMalen_george
12/19/2023, 6:18 AMrp_st
12/19/2023, 9:03 AMrp_st
12/19/2023, 9:04 AMalen_george
12/19/2023, 9:08 AMrp_st
12/19/2023, 9:09 AMalen_george
12/19/2023, 9:14 AMrp_st
12/19/2023, 9:15 AMrp_st
12/19/2023, 9:15 AMrp_st
12/19/2023, 9:16 AMalen_george
12/19/2023, 9:21 AMalen_george
12/20/2023, 11:18 PMthirdPartySignInUpPOST: async function (input) {
try {
if (originalImplementation.thirdPartySignInUpPOST) {
return await originalImplementation.thirdPartySignInUpPOST(input);
}
} catch (err) {
if (err.message === "Cannot sign up as email already exists") {
return {
status: "GENERAL_ERROR",
message: "Seems like you already have an account with another method. Please use that instead."
}
}
throw err;
}
}
Issue now is that, during first time, the we are creating an account using thirdparty google sign in method. but next time when we sign in using the same account , its throwing this error message: 'Seems like you already have an account with another method. Please use that instead.' . Do you have any idea how to fix it?rp_st
12/21/2023, 6:05 AMalen_george
12/21/2023, 1:36 PMthirdPartySignInUp: async function (input) {
if (input.email) {
// let existingUsers = await ThirdPartyPasswordless.getUsersByEmail(input.email);
let existingUsers = await supertokens.listUsersByAccountInfo("public", {
email: input.email
});
if (existingUsers.length === 0) {
// this means this email is new so we allow sign up
return originalImplementation.thirdPartySignInUp(input);
}
if (existingUsers.find(i => "email" in i && "thirdParty" in i && i.thirdParty.id === input.thirdPartyId && i.thirdParty.userId === input.thirdPartyUserId)) {
// this means we are trying to sign in with the same social login. So we allow it
return originalImplementation.thirdPartySignInUp(input);
}
// this means that the email already exists with another social or passwordless login method, so we throw an error.
throw new Error("Cannot sign up as email already exists");
} else {
return originalImplementation.thirdPartySignInUp(input);
}
}
alen_george
12/21/2023, 1:36 PMrp_st
12/21/2023, 1:41 PMalen_george
12/21/2023, 1:44 PMrp_st
12/21/2023, 1:44 PMrp_st
12/21/2023, 1:44 PMalen_george
12/21/2023, 1:48 PMrp_st
12/21/2023, 1:49 PMalen_george
12/21/2023, 1:51 PMthirdPartySignInUp: async function (input) {
if (input.email) {
// let existingUsers = await ThirdPartyPasswordless.getUsersByEmail(input.email);
let existingUsers = await supertokens.listUsersByAccountInfo("public", {
email: input.email
});
console.log(existingUsers);
if (existingUsers.length === 0) {
// this means this email is new so we allow sign up
return originalImplementation.thirdPartySignInUp(input);
}
if (existingUsers.find(i => "email" in i && "thirdParty" in i && i.thirdParty.id === input.thirdPartyId && i.thirdParty.userId === input.thirdPartyUserId)) {
// this means we are trying to sign in with the same social login. So we allow it
return originalImplementation.thirdPartySignInUp(input);
}
// this means that the email already exists with another social or passwordless login method, so we throw an error.
throw new Error("Cannot sign up as email already exists");
} else {
return originalImplementation.thirdPartySignInUp(input);
}
}
alen_george
12/21/2023, 1:52 PMrp_st
12/21/2023, 1:52 PMrp_st
12/21/2023, 1:52 PMalen_george
12/21/2023, 1:53 PMrp_st
12/21/2023, 1:59 PMthirdPartySignInUp: async function (input) {
let existingUsers = await supertokens.listUsersByAccountInfo(input.tenantId, {
email: input.email
});
if (existingUsers.length === 0) {
// this means this email is new so we allow sign up
return originalImplementation.thirdPartySignInUp(input);
}
if (existingUsers.find(u =>
u.loginMethods.find(lM => lM.hasSameThirdPartyInfoAs({
id: input.thirdPartyId,
userId: input.thirdPartyUserId
}) && lM.recipeId === "thirdparty") !== undefined)) {
// this means we are trying to sign in with the same social login. So we allow it
return originalImplementation.thirdPartySignInUp(input);
}
// this means that the email already exists with another social or email password login method, so we throw an error.
throw new Error("Cannot sign up as email already exists");
}
You can see this page for more info: https://supertokens.com/docs/thirdpartyemailpassword/common-customizations/deduplication/implementing-deduplicationalen_george
12/21/2023, 2:06 PMalen_george
12/22/2023, 6:00 AMalen_george
12/22/2023, 6:01 AMcreateCodePOST: async function (input) {
if ("email" in input) {
let existingUsers = await supertokens.listUsersByAccountInfo("public", {
email: input.email
});
if (existingUsers.length === 0) {
// this means this email is new so we allow sign up
if (originalImplementation.createCodePOST) {
return originalImplementation.createCodePOST(input);
}
}
if (existingUsers.find(i => "email" in i && !("thirdParty" in i))) {
// this means that the existing user is a passwordless login user. So we allow it
if (originalImplementation.createCodePOST) {
return originalImplementation.createCodePOST(input);
}
}
return {
status: "GENERAL_ERROR",
message: "Seems like you already have an account with another method. Please use that instead."
}
}
}
alen_george
12/22/2023, 6:01 AMalen_george
12/22/2023, 6:27 AMrp_st
12/22/2023, 6:59 AMrp_st
12/22/2023, 6:59 AMalen_george
12/22/2023, 2:07 PMrp_st
12/22/2023, 2:07 PMalen_george
12/30/2023, 5:59 AMrp_st
12/30/2023, 5:59 AMrp_st
12/30/2023, 5:59 AMalen_george
12/30/2023, 6:00 AMalen_george
12/30/2023, 6:01 AMrp_st
12/30/2023, 6:01 AMalen_george
12/30/2023, 6:01 AMalen_george
12/30/2023, 6:02 AMrp_st
12/30/2023, 6:02 AMalen_george
12/30/2023, 6:05 AMrp_st
12/30/2023, 6:06 AMrp_st
12/30/2023, 6:06 AMRaja I
12/30/2023, 11:32 AMrp_st
12/30/2023, 11:33 AMrp_st
12/30/2023, 11:33 AMRaja I
12/30/2023, 11:34 AMrp_st
12/30/2023, 11:34 AMRaja I
12/30/2023, 11:40 AMRaja I
01/02/2024, 7:28 AMRaja I
01/02/2024, 7:30 AMrp_st
01/02/2024, 7:56 AM