Skip to content

Commit

Permalink
fixes existing code snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
rishabhpoddar committed Dec 19, 2023
1 parent bfc7aee commit 1344c76
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ SuperTokens.init({
input.accessTokenPayload = {
...input.accessTokenPayload,
// highlight-next-line
...(await UserRoleClaim.build(input.userId, input.recipeUserId, input.tenantId, input.userContext))
...(await UserRoleClaim.build(input.userId, input.recipeUserId, input.tenantId, undefined, input.userContext))
};

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ EmailPassword.init({
}

// Call the signup function to create a new SuperTokens user.
let signUpResponse = await EmailPassword.signUp(input.email, input.password, input.userContext)
let signUpResponse = await EmailPassword.signUp(input.tenantId, input.email, input.password, undefined, input.userContext)
if (signUpResponse.status !== "OK") {
throw new Error("Should never come here")
}
Expand All @@ -229,7 +229,7 @@ EmailPassword.init({

if (generateEmailVerificationTokenResponse.status === "OK") {
// Verify the user's email
await EmailVerification.verifyEmailUsingToken("public", generateEmailVerificationTokenResponse.token, input.userContext);
await EmailVerification.verifyEmailUsingToken("public", generateEmailVerificationTokenResponse.token, undefined, input.userContext);
}
}

Expand Down Expand Up @@ -493,7 +493,7 @@ EmailPassword.init({
if (legacyUserInfo) {
// create a SuperTokens account for the user with a temporary password
let tempPassword = await generatePassword();
let signUpResponse = await EmailPassword.signUp(email, tempPassword, input.userContext);
let signUpResponse = await EmailPassword.signUp(input.tenantId, email, tempPassword, undefined, input.userContext);

if (signUpResponse.status === "OK") {

Expand All @@ -510,7 +510,7 @@ EmailPassword.init({

if (generateEmailVerificationTokenResponse.status === "OK") {
// verify the user's email
await EmailVerification.verifyEmailUsingToken("public", generateEmailVerificationTokenResponse.token, input.userContext);
await EmailVerification.verifyEmailUsingToken("public", generateEmailVerificationTokenResponse.token, undefined, input.userContext);
}
}

Expand Down Expand Up @@ -975,7 +975,7 @@ EmailPassword.init({
}
}
// Call the signup function to create a new SuperTokens user.
let signUpResponse = await EmailPassword.signUp(input.email, input.password, input.userContext)
let signUpResponse = await EmailPassword.signUp(input.tenantId, input.email, input.password, undefined, input.userContext)
if (signUpResponse.status !== "OK") {
throw new Error("Should never come here")
}
Expand All @@ -993,7 +993,7 @@ EmailPassword.init({

if (generateEmailVerificationTokenResponse.status === "OK") {
// Verify the user's email
await EmailVerification.verifyEmailUsingToken("public", generateEmailVerificationTokenResponse.token, input.userContext);
await EmailVerification.verifyEmailUsingToken("public", generateEmailVerificationTokenResponse.token, undefined, input.userContext);
}
}

Expand Down
29 changes: 29 additions & 0 deletions v2/mfa/backend-setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,36 @@ hide_title: true
---

import MFAPaidBanner from '../community/reusableMD/mfa/MFAPaidBanner.mdx'
import BackendSDKTabs from "/src/components/tabs/BackendSDKTabs";

<MFAPaidBanner />

# Backend setup

We start by intialising the MFA recipe on the backend and specifying the list of first factors using their [factor IDs](./important-concepts#auth-factor-ids). You still have to initialise all the auth recipes in the `recipeList`, and configure them based on your needs.

For example, the code below inits `thirdpartyemailpassword` and `passwordless` recipes and sets the `firstFactor` array to be `["emailpassword", "thirdparty"]`. This means that we will show email password and social login to the user as the first factor (using the `thirdpartyemailpassword` recipe), and use `passwordless` for the second factor.

<BackendSDKTabs>
<TabItem value="nodejs">

```ts
TODO
```

</TabItem>
<TabItem value="go">

:::note
Coming soon. In the meantime, checkout the [legacy method](./legacy-method/how-it-works) for adding MFA to your app.
:::

</TabItem>
<TabItem value="python">

:::note
Coming soon. In the meantime, checkout the [legacy method](./legacy-method/how-it-works) for adding MFA to your app.
:::

</TabItem>
</BackendSDKTabs>
2 changes: 1 addition & 1 deletion v2/mfa/backend/first-factor.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ Session.init({
accessTokenPayload: {
...input.accessTokenPayload,
// highlight-next-line
...(await SecondFactorClaim.build(input.userId, input.recipeUserId, input.tenantId, input.userContext)),
...(await SecondFactorClaim.build(input.userId, input.recipeUserId, input.tenantId, undefined, input.userContext)),
},
});
},
Expand Down
4 changes: 2 additions & 2 deletions v2/mfa/backend/second-factor.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ Session.init({
...input,
accessTokenPayload: {
...input.accessTokenPayload,
...(await SecondFactorClaim.build(input.userId, input.recipeUserId, input.tenantId, input.userContext)),
...(await SecondFactorClaim.build(input.userId, input.recipeUserId, input.tenantId, undefined, input.userContext)),
},
});
},
Expand Down Expand Up @@ -1228,7 +1228,7 @@ Session.init({
...input,
accessTokenPayload: {
...input.accessTokenPayload,
...(await SecondFactorClaim.build(input.userId, input.recipeUserId, input.tenantId, input.userContext)),
...(await SecondFactorClaim.build(input.userId, input.recipeUserId, input.tenantId, undefined, input.userContext)),
// highlight-next-line
phoneNumber,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ SuperTokens.init({
input.accessTokenPayload = {
...input.accessTokenPayload,
// highlight-next-line
...(await UserRoleClaim.build(input.userId, input.recipeUserId, input.tenantId, input.userContext))
...(await UserRoleClaim.build(input.userId, input.recipeUserId, input.tenantId, undefined, input.userContext))
};

/*
Expand Down
2 changes: 1 addition & 1 deletion v2/phonepassword/backend/passwordless-customisation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ supertokens.init({
...input,
accessTokenPayload: {
...input.accessTokenPayload,
...PhoneVerifiedClaim.build(input.userId, input.recipeUserId, input.tenantId, input.userContext),
...PhoneVerifiedClaim.build(input.userId, input.recipeUserId, input.tenantId, undefined, input.userContext),
phoneNumber: userInfo?.emails[0],
},
});
Expand Down
2 changes: 1 addition & 1 deletion v2/phonepassword/backend/session-customisation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ supertokens.init({
...input,
accessTokenPayload: {
...input.accessTokenPayload,
...PhoneVerifiedClaim.build(input.userId, input.recipeUserId, input.tenantId, input.userContext),
...PhoneVerifiedClaim.build(input.userId, input.recipeUserId, input.tenantId, undefined, input.userContext),
phoneNumber: userInfo?.emails[0],
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ SuperTokens.init({
input.accessTokenPayload = {
...input.accessTokenPayload,
// highlight-next-line
...(await UserRoleClaim.build(input.userId, input.recipeUserId, input.tenantId, input.userContext))
...(await UserRoleClaim.build(input.userId, input.recipeUserId, input.tenantId, undefined, input.userContext))
};

/*
Expand Down
2 changes: 1 addition & 1 deletion v2/src/plugins/codeTypeChecking/jsEnv/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"socket.io": "^4.6.1",
"socketio": "^1.0.0",
"supertokens-auth-react": "^0.36.0",
"supertokens-node": "^16.5.0",
"supertokens-node": "github:supertokens/supertokens-node#feat/mfa/base",
"supertokens-node7": "npm:[email protected]",
"supertokens-react-native": "^4.0.0",
"supertokens-web-js": "^0.8.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ SuperTokens.init({
input.accessTokenPayload = {
...input.accessTokenPayload,
// highlight-next-line
...(await UserRoleClaim.build(input.userId, input.recipeUserId, input.tenantId, input.userContext))
...(await UserRoleClaim.build(input.userId, input.recipeUserId, input.tenantId, undefined, input.userContext))
};

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ SuperTokens.init({
input.accessTokenPayload = {
...input.accessTokenPayload,
// highlight-next-line
...(await UserRoleClaim.build(input.userId, input.recipeUserId, input.tenantId, input.userContext))
...(await UserRoleClaim.build(input.userId, input.recipeUserId, input.tenantId, undefined, input.userContext))
};

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ ThirdPartyEmailPassword.init({
}

// Call the signup function to create a new SuperTokens user.
let signUpResponse = await ThirdPartyEmailPassword.emailPasswordSignUp(input.email, input.password, input.userContext);
let signUpResponse = await ThirdPartyEmailPassword.emailPasswordSignUp(input.tenantId, input.email, input.password, undefined, input.userContext);
if (signUpResponse.status !== "OK") {
throw new Error("Should never come here")
}
Expand All @@ -227,7 +227,7 @@ ThirdPartyEmailPassword.init({

if (generateEmailVerificationTokenResponse.status === "OK") {
// Verify the user's email
await EmailVerification.verifyEmailUsingToken("public", generateEmailVerificationTokenResponse.token, input.userContext);
await EmailVerification.verifyEmailUsingToken("public", generateEmailVerificationTokenResponse.token, undefined, input.userContext);
}
}

Expand Down Expand Up @@ -516,7 +516,7 @@ ThirdPartyEmailPassword.init({
if (legacyUserData) {
// create a SuperTokens account for the user with a temporary password
let tempPassword = await generatePassword();
let signupResponse = await ThirdPartyEmailPassword.emailPasswordSignUp(email, tempPassword, input.userContext);
let signupResponse = await ThirdPartyEmailPassword.emailPasswordSignUp(input.tenantId, email, tempPassword, undefined, input.userContext);

if (signupResponse.status === "OK") {

Expand All @@ -533,7 +533,7 @@ ThirdPartyEmailPassword.init({

if (generateEmailVerificationTokenResponse.status === "OK") {
// Verify the user's email
await EmailVerification.verifyEmailUsingToken("public", generateEmailVerificationTokenResponse.token, input.userContext);
await EmailVerification.verifyEmailUsingToken("public", generateEmailVerificationTokenResponse.token, undefined, input.userContext);
}
}

Expand Down Expand Up @@ -1042,7 +1042,7 @@ ThirdPartyEmailPassword.init({
}

// Call the signup function to create a new SuperTokens user.
let signUpResponse = await ThirdPartyEmailPassword.emailPasswordSignUp(input.email, input.password, input.userContext);
let signUpResponse = await ThirdPartyEmailPassword.emailPasswordSignUp(input.tenantId, input.email, input.password, undefined, input.userContext);
if (signUpResponse.status !== "OK") {
throw new Error("Should never come here")
}
Expand All @@ -1060,7 +1060,7 @@ ThirdPartyEmailPassword.init({

if (generateEmailVerificationTokenResponse.status === "OK") {
// Verify the user's email
await EmailVerification.verifyEmailUsingToken("public", generateEmailVerificationTokenResponse.token, input.userContext);
await EmailVerification.verifyEmailUsingToken("public", generateEmailVerificationTokenResponse.token, undefined, input.userContext);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ SuperTokens.init({
input.accessTokenPayload = {
...input.accessTokenPayload,
// highlight-next-line
...(await UserRoleClaim.build(input.userId, input.recipeUserId, input.tenantId, input.userContext))
...(await UserRoleClaim.build(input.userId, input.recipeUserId, input.tenantId, undefined, input.userContext))
};

/*
Expand Down

0 comments on commit 1344c76

Please sign in to comment.