Hey <@498057949541826571> for older version of supertoken node - 12.x.x , do we have multitenancy a...
a
Hey @rp_st for older version of supertoken node - 12.x.x , do we have multitenancy as the recipe ? const Multitenancy = require("supertokens-node/recipe/multitenancy"); I couldn't find this file. Its throwing an error.
r
hey @alen_george we don't. You will have to update to newer versions.
You can see our changelog in the node and frontend repo for steps to upgrade.
a
Can we use the curl method directly just to test it without upgrading ? I was following this to create a new tenant : On making a request it says , not found.
r
You can. Sure. However, the full integration will not work without updating the backend SDK.
You may also need to update the core (i don't know the version you are using right now), but for that, you can email us from your registered email ID
a
I did a make cURL call, using Postman, it returns not found. We are using these versions right now. "supertokens-node": "^12.1.1" "supertokens-web-js": "^0.3.0",
r
what version of the core are you running?
a
Development Environment (v4.1) IS this the one ? Where can I find it ?
r
yea
u will need to update this
you can email us on rishabh@supertokens.com for the update from your registered emial id
a
Sure, I will do that.
Hey we have dropped a mail as requested.
Hi @rp_st Did you guys upgrade the core ?
r
we will do it today
for the dev env
a
And for the prod, how are we supposed to do ?
r
same process. But i would first recommend that you finish the whole setup in dev, and then we can update prod
a
sure will do that. Why is the core not automatically updated ? Will we have to do it every time ? Also if possible can you please try to quickly update the dev env.
r
Hey @alen_george We have upated your dev env.
core updates are not automatic. Each time you want to upgrade the core for an envorinemtn, you will have to email us. That being said, we are working on making it automatic via a button on the dashboard, but the timeline for that is unkonwn
a
Thanks for the update, we have observed that the current core version is 5.0 and I have updated the packages for backend and frontend to the latest one's. We are getting an error while making calls which says 'Error: The running SuperTokens core version is not compatible with this NodeJS SDK.' . Our current newer versions are: Frontend : "supertokens-web-js": "^0.8.0", Backend : "supertokens-node": "^16.6.8"
r
can you send a screenshot of what you see on the supertokens.com dashboard please?
a
r
right ok! on it. Sorry for the confusion
can you refresh the page?
it should show the right version now
a
Hey thanks, its showing latest version now.
Hi @rp_st , We have used email and thirdparty passwordless recipe. So for that earlier our code looked something like this where we had written few conditions for performing specific scenarios after getting suggestions from you.
Copy code
thirdPartySignInUpPOST: 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?
r
can i see the override for thirdPartySignInUp in override.functions?
a
Copy code
thirdPartySignInUp: 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);
                            }
                        }
This is the thirdPartySigninUp override which we were doing earlier.
r
which part of this is the execution coming in when you try and sign in with google?
a
All the third party apps.
r
huh?
could you tell me which part of the function the execution comes into?
a
Its throwing this error : throw new Error("Cannot sign up as email already exists"); Its not entering any of the if condition
r
could you repost the code with proper formatting?
a
Copy code
thirdPartySignInUp: 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);
    }
}
For existing users Im getting this log : [ User { id: '5022b513-ed0d-4976-81b5-05f06be62e95', isPrimaryUser: false, tenantIds: [ 'public' ], emails: [ 'alen01@gmail.com' ], phoneNumbers: [], thirdParty: [ [Object] ], timeJoined: 1703033843084, loginMethods: [ [LoginMethod] ] } ]
r
could you use three back ticks please?
this is hard for me to read
a
is it good now ?
r
Change the function to:
Copy code
thirdPartySignInUp: 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-deduplication
a
Thanks a lot, Iwill try this out.
Hey a quick question ? How can I modify the consumeCodePost for the email sign in method. Im facing same issue like thirdparty where second time if I sign in its not allowing.
Copy code
createCodePOST: 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."
        }
    }
}
a
Thanks
One quick question, how much time would it take to upgrade the supertokens core for production ?
r
1 business day.
the actual downtime would be a few seconds.
a
Do we have to mail you again for the upgrade of production core?
r
yup
a
We were trying to add a new tenant in development. 'Just getting this message 'EntityID already exists for different tenant/product'. Is Entity Id same as the tenant id ?
r
no
you are adding this in SAML?
a
Im using the mock saml metadata to test.
how to delete dev tenants if I already have created earlier?
r
in boxyhq or in supertokens?
a
both side.
Im getting this error while making a call to get the client id and secret 'EntityID already exists for different tenant/product'
r
see the API spec please: https://app.swaggerhub.com/apis/supertokens/CDI and also refer to boxy hq docs on their site.
a
how to solve this ? Whatever new tenant Id Im giving, Im not able to get the client id and secret. Im getting this error while making a call to get the client id and secret 'EntityID already exists for different tenant/product'. Is there any way to reset this ?
r
you should remove the existing tenant
see the docs and api spec please.
r
Hi we have created only one tenant, which is listed on http://localhost:8080/auth/dashboard/ public and uosc
r
This error is coming from boxyhq. Can you join their discord and ask them please?
Or, if you want us to guide you, you can start a support subscription with us.
r
Sure. I will check with them. Can you share us the details about support subscription?
r
DMing u
r
Sure
Hi @rp_st I have send you an email for production upgrade.
Today we have to roll out SSO for our enterprise customer in production. Your help will be more helpful for us to implement and launch.
r
Doing it now
9 Views