david_61794
10/31/2023, 3:27 PMgetUser or I just don’t understand how user id mapping is supposed to work between recipe user ids and external ids.
Currently we’re mapping our users to an external id with createUserIdMapping after signing them up. We then verify their emails using the external id as it’s the id returned by calling getUser. Once the email is verified, a row is added to emailverification_verified_emails with the external user id as the user_id in the database.
This works well as the email verification claim st-ev is true in the access token jwt and if I call isEmailVerified with the external user id converted to a recipe user id then it returns true.
The problem seems to be with getUser as it returns a list of loginMethods but the verified flag is false even though isEmailVerified returns true if I check using the same recipeUserId and email returned in the login method. The email verification claim for this user is true in the access token too.
However if I change the logic to verify the email based on the supertokens user id instead, then getUser will return the login method verified as true but the email verification claim st-ev is false.
I may be misunderstanding how the different ids are supposed to be used but it seems like getUser may be returning the verification status of the email login method incorrectly please?rp_st
10/31/2023, 3:32 PMrp_st
10/31/2023, 3:32 PMrp_st
10/31/2023, 3:35 PMdavid_61794
10/31/2023, 3:39 PMrp_st
10/31/2023, 3:40 PMrp_st
10/31/2023, 3:44 PMrp_st
10/31/2023, 3:49 PMrp_st
10/31/2023, 3:56 PMdavid_61794
10/31/2023, 4:06 PMsendEmailVerificationEmail with the external id as the user id and recipe user id which is probably where the issue is coming from then as you say. I believe when upgrading to the most recent version os Supertokens, we were having issues with sending the emails after passing in the recipe user id from the signup call so just went with using the external id as it appeared to be working.david_61794
10/31/2023, 4:08 PMsendEmailVerificationEmail should we just be using the supertokens user id (instead of external id) and the recipe user id from the signup call then?rp_st
10/31/2023, 4:25 PMrp_st
10/31/2023, 4:26 PMdavid_61794
10/31/2023, 4:34 PMemailPasswordSignup we've got:
const response =
await originalImplementation.emailPasswordSignUp(input);
await supertokens.createUserIdMapping({
superTokensUserId: response.user.id,
externalUserId: input.userContext.externalUserId,
});
const updatedUser = await supertokens.getUser(
input.userContext.externalUserId,
);
// With the mapping update, the id and login methods have changed so update the response so that the session creation after this succeeds
response.user = updatedUser;
response.recipeUserId = supertokens.convertToRecipeUserId(
input.userContext.externalUserId,
);
await EmailVerification.sendEmailVerificationEmail(
"public",
response.user.id,
response.recipeUserId,
);rp_st
10/31/2023, 4:40 PMupdatedUser.loginMethods[0].recipeUserId the external user ID as well? Or a UUID that we generate?david_61794
10/31/2023, 4:51 PMrp_st
10/31/2023, 4:51 PMrp_st
10/31/2023, 4:51 PMrp_st
10/31/2023, 4:51 PMdavid_61794
10/31/2023, 4:53 PMuser.id will either be the external mapped id or the supertokens generated id if there is no mapped id?rp_st
10/31/2023, 4:55 PMdavid_61794
10/31/2023, 4:56 PMsueprtokens-core nowrp_st
10/31/2023, 4:57 PMrp_st
11/01/2023, 1:45 PM7.0. If the error persists, lmkSuperTokens is an open source authentication solution offering features like: Different types of login: Email / password, Passwordless (OTP or Magic link based).
Powered by