Skip to content

Commit

Permalink
fixes to snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
rishabhpoddar committed May 13, 2024
1 parent b6f5b7d commit 65d47f2
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
2 changes: 2 additions & 0 deletions v2/mfa/backend-setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ For a multi tenancy setup, where each tenant can have a different set of first f

```tsx
import Multitenancy from "supertokens-node/recipe/multitenancy";
import MultiFactorAuth from "supertokens-node/recipe/multifactorauth"

async function createNewTenant() {
let resp = await Multitenancy.createOrUpdateTenant("customer1", {
Expand Down Expand Up @@ -532,6 +533,7 @@ For a multi tenant setup, you can configure a list of secondary factors when cre

```tsx
import Multitenancy from "supertokens-node/recipe/multitenancy";
import MultiFactorAuth from "supertokens-node/recipe/multifactorauth"

async function createNewTenant() {
let resp = await Multitenancy.createOrUpdateTenant("customer1", {
Expand Down
4 changes: 2 additions & 2 deletions v2/mfa/email-sms-otp/otp-for-all-users.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ supertokens.init({
firstFactors: [
MultiFactorAuth.FactorIds.EMAILPASSWORD,
MultiFactorAuth.FactorIds.THIRDPARTY
]
],
// highlight-start
override: {
functions: (originalImplementation) => {
Expand Down Expand Up @@ -498,7 +498,7 @@ async function createNewTenant() {
firstFactors: [
MultiFactorAuth.FactorIds.EMAILPASSWORD,
MultiFactorAuth.FactorIds.THIRDPARTY
]
],
requiredSecondaryFactors: [MultiFactorAuth.FactorIds.OTP_EMAIL]
});

Expand Down
6 changes: 3 additions & 3 deletions v2/mfa/email-sms-otp/otp-for-opt-in-users.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ supertokens.init({
firstFactors: [
MultiFactorAuth.FactorIds.EMAILPASSWORD,
MultiFactorAuth.FactorIds.THIRDPARTY
]
],
// highlight-start
override: {
functions: (originalImplementation) => {
Expand Down Expand Up @@ -425,7 +425,7 @@ supertokens.init({
firstFactors: [
MultiFactorAuth.FactorIds.EMAILPASSWORD,
MultiFactorAuth.FactorIds.THIRDPARTY
]
],
override: {
functions: (originalImplementation) => {
return {
Expand Down Expand Up @@ -541,7 +541,7 @@ supertokens.init({
firstFactors: [
MultiFactorAuth.FactorIds.EMAILPASSWORD,
MultiFactorAuth.FactorIds.THIRDPARTY
]
],
// highlight-start
override: {
functions: (originalImplementation) => {
Expand Down
8 changes: 4 additions & 4 deletions v2/mfa/step-up-auth.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ async function shouldLoadRoute(): Promise<boolean> {
// since all default claim validators have passed, we now check for if the user has finished TOTP
// within the last 5 mins
let mfaClaimValue = await Session.getClaimValue({ claim: MultiFactorAuthClaim });
let totpCompletedTime = mfaClaimValue?.c[MultiFactorAuth.FactorIds.TOTP];
let totpCompletedTime = mfaClaimValue?.c["totp"];
if (totpCompletedTime === undefined || totpCompletedTime < (DateProviderReference.getReferenceOrThrow().dateProvider.now() - 1000 * 60 * 5)) {
// ths user needs to complete TOTP since it's been more than 5 mins since they completed it.
return false;
Expand Down Expand Up @@ -693,7 +693,7 @@ async function shouldLoadRoute(): Promise<boolean> {
// since all default claim validators have passed, we now check for if the user has finished TOTP
// within the last 5 mins
let mfaClaimValue = await Session.getClaimValue({ claim: MultiFactorAuthClaim });
let totpCompletedTime = mfaClaimValue?.c[MultiFactorAuth.FactorIds.TOTP];
let totpCompletedTime = mfaClaimValue?.c["totp"];
if (totpCompletedTime === undefined || totpCompletedTime < (DateProviderReference.getReferenceOrThrow().dateProvider.now() - 1000 * 60 * 5)) {
// ths user needs to complete TOTP since it's been more than 5 mins since they completed it.
return false;
Expand Down Expand Up @@ -723,7 +723,7 @@ async function shouldLoadRoute(): Promise<boolean> {
// since all default claim validators have passed, we now check for if the user has finished TOTP
// within the last 5 mins
let mfaClaimValue = await supertokensSession.getClaimValue({ claim: supertokensMultiFactorAuth.MultiFactorAuthClaim });
let totpCompletedTime = mfaClaimValue?.c[MultiFactorAuth.FactorIds.TOTP];
let totpCompletedTime = mfaClaimValue?.c["totp"];
if (totpCompletedTime === undefined || totpCompletedTime < (supertokensDateProviderReference.DateProviderReference.getReferenceOrThrow().dateProvider.now() - 1000 * 60 * 5)) {
// ths user needs to complete TOTP since it's been more than 5 mins since they completed it.
return false;
Expand Down Expand Up @@ -763,7 +763,7 @@ async function checkIfMFAIsCompleted() {
let isMFACompleted: boolean = (await SuperTokens.getAccessTokenPayloadSecurely())["st-mfa"].v;
if (isMFACompleted) {
let completedFactors = (await SuperTokens.getAccessTokenPayloadSecurely())["st-mfa"].c;
if (completedFactors[MultiFactorAuth.FactorIds.TOTP] === undefined || completedFactors[MultiFactorAuth.FactorIds.TOTP] < (Date.now() - 1000*60*5)) {
if (completedFactors["totp"] === undefined || completedFactors["totp"] < (Date.now() - 1000*60*5)) {
// user has not finished TOTP MFA in the last 5 minutes
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion v2/mfa/totp/totp-for-all-users.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ async function createNewTenant() {
firstFactors: [
MultiFactorAuth.FactorIds.EMAILPASSWORD,
MultiFactorAuth.FactorIds.THIRDPARTY
]
],
requiredSecondaryFactors: [MultiFactorAuth.FactorIds.OTP_EMAIL]
});

Expand Down

0 comments on commit 65d47f2

Please sign in to comment.