ITEnthusiasm
01/08/2024, 6:47 PMsupertokens-node
to latest, I'm probably going to update the example Remix/SvelteKit repos to work with the latest version. Are there any other incoming breaking changes that I should be aware of before migrating those examples to the latest version?ITEnthusiasm
01/08/2024, 7:42 PMEmailPassword.getUserByEmail
is deprecated. So I'd have to use SuperTokens.listUsersByAccountInfo
. Would that look like this?
ts
import SuperTokens from "supertokens-node";
const users = await SuperTokens.listUsersByAccountInfo("public", { email: "email@example.com" });
if (users.length === 0) // User does not exist ...
My main concern is if I should be importing from supertokens-node
or something else like supertokens-node/build
. Does it matter?
Also is this performant? ๐
I would think it would be preferable to get just one user at a time, no? Or is this related to multi-tenancy?ITEnthusiasm
01/08/2024, 7:44 PMlistUsersByAccountInfo
deal. If I'm just using a regular EmailPassword
recipe, is there any chance that the array returned to me will be larger than 1?
I guess the real question is... In what scenarios will this list return me more than 1 users for a single email?ITEnthusiasm
01/08/2024, 7:56 PMEmailPassword.sendEmail
over EmailPassword.sendPasswordResetLink
or vice versa?ITEnthusiasm
01/08/2024, 7:57 PMEmailPassword.sendEmail
ever support the new verification link option?ITEnthusiasm
01/08/2024, 8:09 PMconsumePasswordResetToken
and resetPasswordUsingToken
? (Or rather, why would I use consume
instead?)ITEnthusiasm
01/08/2024, 8:23 PMrp_st
01/09/2024, 7:14 AM/build
path. Also, it is performant. We have an index on the email.
> If I'm just using a regular EmailPassword recipe, is there any chance that the array returned to me will be larger than 1?
it would be 0 or 1.
> Is there a reason to prefer EmailPassword.sendEmail over EmailPassword.sendPasswordResetLink or vice versa?
One reason you may want to use sendEmail is cause it allows you to customise the link however you like before calling the function. Otherwise, it doesn't matter.
> Will EmailPassword.sendEmail ever support the new verification link option?
You mean email verification? Thats a different recipe.
> What's the difference between consumePasswordResetToken and resetPasswordUsingToken? (Or rather, why would I use consume instead?)
consumePasswordResetToken just checks if the code is OK and deletes it from the db. The other function calls consumePasswordResetToken, and if it's OK, then also calls the change in the user's password.ITEnthusiasm
01/09/2024, 3:50 PMITEnthusiasm
01/09/2024, 4:11 PMts
let userId = "userId"; // get from db
let session = await Session.createNewSessionWithoutRequestResponse("public", supertokens.convertToRecipeUserId(userId));
Currently, my signup
helper looks something like this:
ts
const helpers = {
// ... Other Helpers ...
async signup(email: string, password: string): Promise<SignUpResult> {
const signupResult = await EmailPassword.signUp(tenantId, email, password);
if (signupResult.status === "EMAIL_ALREADY_EXISTS_ERROR") return { status: signupResult.status };
const { status, user } = signupResult;
const session = await Session.createNewSessionWithoutRequestResponse(user.id);
return { status, tokens: session.getAllSessionTokensDangerously() };
}
}
Do I need to change user.id
to SuperTokens.convertToRecipeUserId(user.id)
? And will I need to do this in every situation where I get the user
as a result of calling a method on the EmailPassword
recipe?
I still haven't gotten to study what the new RecipeUserId
means yet and wrap my head around it. I'm still working through the Changelog.rp_st
01/09/2024, 4:16 PMITEnthusiasm
01/09/2024, 4:26 PMITEnthusiasm
01/09/2024, 4:59 PMuser
object safe to use in all other parts of a web application? I only need to use RecipeUserId
when doing specific things like creating sessions?rp_st
01/09/2024, 5:00 PMITEnthusiasm
01/09/2024, 5:14 PMEmailPassword.sendEmail
now:
ts
export declare type TypeEmailPasswordPasswordResetEmailDeliveryInput = {
type: "PASSWORD_RESET";
user: {
id: string;
recipeUserId: RecipeUserId | undefined;
email: string;
};
passwordResetLink: string;
tenantId: string;
};
Are there specific circumstances where the RecipeUserId
is required? Or is it always optional?ITEnthusiasm
01/09/2024, 5:15 PMrp_st
01/09/2024, 5:24 PMITEnthusiasm
01/09/2024, 5:27 PMrp_st
01/09/2024, 5:28 PMrp_st
01/09/2024, 5:29 PM