Hey, after updating to version 7 of supertokens co...
# support-questions-legacy
f
Hey, after updating to version 7 of supertokens core and version 16 of supertokens-node, I'm facing following error during user signup.
Copy code
Error: UNKNOWN_USER_ID
    at EmailVerificationClaimClass.fetchValue (/Users/f//backend/node_modules/supertokens-node/lib/build/recipe/emailverification/emailVerificationClaim.js:31:27)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at EmailVerificationClaimClass.build (/Users/f/backend/node_modules/supertokens-node/lib/build/recipe/session/types.js:9:23)
    at Object.createNewSessionInRequest (/Users/f/backend/node_modules/supertokens-node/lib/build/recipe/session/sessionRequestFunctions.js:351:24)
    at Function.createNewSession (/Users/f/backend/node_modules/supertokens-node/lib/build/recipe/session/index.js:48:16)
    at Object.signUpPOST /Users/f/backend/node_modules/supertokens-node/lib/build/recipe/emailpassword/api/implementation.js:561:27)
    at Object.emailPasswordSignUpPOST (/Users/f/backend/apps/supertokens-service/src/supertokens/services/recipes/third-party-email-password.overrides.ts:561:22)...
Not sure it this could be the cause, but at the end of emailPasswordSignUp we call
Copy code
const response = await originalImplementation.emailPasswordSignUp(
          input,
        );

    /* code for fetching external user */

    await createUserIdMapping({
          superTokensUserId: response.user.id,
          externalUserId: external.user.id,
        });

    response.user.id = external.user.id;
    return response;
We are using: image: registry.supertokens.io/supertokens/supertokens-postgresql:7.0
r
Hey @fdundjer
@sattvikc can help here tomorrow
s
@fdundjer please update the override to something like this to fix the issue:
Copy code
ts
emailPasswordSignUp: async (input) => {
    const resp = await oI.emailPasswordSignUp(input);

    if (resp.status === "OK") {
        /* code to fetch external user id */
        const externaluserId = 'euid1';

        await supertokens.createUserIdMapping({
            superTokensUserId: resp.user.id,
            externalUserId: externaluserId,
        })
        resp.user.id = externaluserId;
        resp.user.loginMethods[0].recipeUserId = new RecipeUserId(externaluserId);
        return resp;
    }
    return resp;
}
r
and you can import RecipeUserId from
import { RecipeUserId } from "supertokens-node";
f
Thanks, that solved the UNKNOW_USER_ID issue. Still, our integration tests are failing after update. On third party signup, email verification claim returns false. Previously it was returning true.
Copy code
const accessToken = result.accessToken;
      const session = await Session.getSessionWithoutRequestResponse(
        accessToken,
        undefined,
        {
          overrideGlobalClaimValidators: () => [],
        },
      );
      const payload = session.getAccessTokenPayload();
      expect(payload.name).toEqual(testUserFullName);
      const emailVerificationClaim = await session.getClaimValue(
        EmailVerificationClaim,
      );
      expect(emailVerificationClaim).toEqual(true); // THIS FAILS
I've seen that you have added new
isVerified
to thirdpartysignups, I'll check what it does. I guess thats the issue.
s
do you have a userid mapping for thirdparty user as well ?
f
Yes, but I've updated the code the same way as on email+pass
s
ok, let me see and get back
f
We override getUserInfo for our provider in unit tests. This is the return value:
Copy code
return Promise.resolve(<UserInfo>{
        thirdPartyUserId: testUserThirdPartyId,
        email: {
          id: testUserEmail1,
          isVerified: true,
        },
        rawUserInfoFromProvider: {
          fromUserInfoAPI: {
            id: testUserThirdPartyId,
            email: testUserEmail1,
          },
        },
      });
s
yea, this is fine
there might be a bug, give me a moment. I'll get back
I think there is bug in the core related to this, which I will discuss internally. meanwhile, you could fix the issues as per the snippet below:
Copy code
ts
const resp = await oI.thirdPartySignInUp(input);

if (resp.status === "OK") {
    const externalUserId = 'euid2';

    await supertokens.createUserIdMapping({
        superTokensUserId: resp.user.id,
        externalUserId: externalUserId,
    })
    resp.user.id = externalUserId;
    resp.user.loginMethods[0].recipeUserId = new RecipeUserId(externalUserId);

    if (input.isVerified) {
        const token = await EmailVerification.createEmailVerificationToken(input.tenantId, new RecipeUserId(externalUserId), input.email, input.userContext)
        if(token.status == "OK") {
            await EmailVerification.verifyEmailUsingToken(input.tenantId, token.token);
        }
    }
}

return resp;
f
Thanks, I'll test it out asap
All tests are passing right now. Thanks! Please let me know when there is fix, so we can remove workaround 🙂
s
was ur createUserIdMapping call to the core was passing ?
for thirdParty sign in up
f
yes, response status OK
And I can see in the core that call was made:
Copy code
2023-11-09 10:54:08 09 Nov 2023 09:54:08:037 +0000 | INFO | pid: f3770fe7-5b76-481d-b41e-fc5196ea59fe | [http-nio-0.0.0.0-3567-exec-1] thread | io.supertokens.webserver.WebserverAPI.service(WebserverAPI.java:436) | Tenant(, public, public) | API called: /recipe/userid/map. Method: POST. Version: 4.0
s
what versions of core and SDK are you using ?
f
"supertokens-node": "^16.4.0", image: registry.supertokens.io/supertokens/supertokens-postgresql:7.0
s
ok cool, thank you
r
@fdundjer we have fixed this issue. You can try again with the workaround removed. If you are using our managed service, then you don't have to worry about updating the core. For self hosted, repull the latest image (tag is 7.0)
f
@rp_st I can confirm that issue is fixed with latest image. Thanks!
r
perfect!
7 Views