Skip to content

Commit

Permalink
more changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rishabhpoddar committed Apr 9, 2024
1 parent 7889e84 commit 12662eb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 32 deletions.
18 changes: 2 additions & 16 deletions v2/mfa/email-sms-otp/otp-for-opt-in-users.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ supertokens.init({
getMFARequirementsForAuth: async function (input) {
let roles = await UserRoles.getRolesForUser(input.tenantId, (await input.user).id)
// highlight-next-line
if (roles.roles.includes("admin") && await shouldRequireOTPEmailForTenant(input.tenantId)) {
if (roles.roles.includes("admin") && (await input.requiredSecondaryFactorsForTenant).includes("otp-email")) {
// we only want otp-email for admins
return ["otp-email"]
} else {
Expand All @@ -438,13 +438,6 @@ supertokens.init({
})
]
})

// highlight-start
async function shouldRequireOTPEmailForTenant(tenantId: string): Promise<boolean> {
// your logic here to determine if we care about otp-email for this tenant or not.
return true;
}
// highlight-end
```

</TabItem>
Expand Down Expand Up @@ -544,7 +537,7 @@ supertokens.init({
...originalImplementation,
getMFARequirementsForAuth: async function (input) {
if ((await input.requiredSecondaryFactorsForUser).includes("otp-email")) {
if (await shouldRequireOTPEmailForTenant(input.tenantId)) {
if ((await input.requiredSecondaryFactorsForTenant).includes("otp-email")) {
return ["otp-email"]
}
}
Expand All @@ -558,13 +551,6 @@ supertokens.init({
})
]
})

// highlight-start
async function shouldRequireOTPEmailForTenant(tenantId: string): Promise<boolean> {
// your logic here to determine if we care about otp-email for this tenant or not.
return true;
}
// highlight-end
```

</TabItem>
Expand Down
18 changes: 2 additions & 16 deletions v2/mfa/totp/totp-for-opt-in-users.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ supertokens.init({
getMFARequirementsForAuth: async function (input) {
let roles = await UserRoles.getRolesForUser(input.tenantId, (await input.user).id)
// highlight-next-line
if (roles.roles.includes("admin") && await shouldRequireTotpForTenant(input.tenantId)) {
if (roles.roles.includes("admin") && (await input.requiredSecondaryFactorsForTenant).includes("totp")) {
// we only want totp for admins
return ["totp"]
} else {
Expand All @@ -625,13 +625,6 @@ supertokens.init({
})
]
})

// highlight-start
async function shouldRequireTotpForTenant(tenantId: string): Promise<boolean> {
// your logic here to determine if we care about totp for this tenant or not.
return true;
}
// highlight-end
```

</TabItem>
Expand Down Expand Up @@ -710,7 +703,7 @@ supertokens.init({
getMFARequirementsForAuth: async function (input) {
if ((await input.requiredSecondaryFactorsForUser).includes("totp")) {
// this means that the user has finished setting up a device from their settings page.
if (await shouldRequireTotpForTenant(input.tenantId)) {
if ((await input.requiredSecondaryFactorsForTenant).includes("totp")) {
return ["totp"]
}
}
Expand All @@ -724,13 +717,6 @@ supertokens.init({
})
]
})

// highlight-start
async function shouldRequireTotpForTenant(tenantId: string): Promise<boolean> {
// your logic here to determine if we care about totp for this tenant or not.
return true;
}
// highlight-end
```

</TabItem>
Expand Down

0 comments on commit 12662eb

Please sign in to comment.