Update 2FA Organization Requirement - PropelAuth Docs
Update 2FA Organization Requirement Component
PropelAuth's Update 2FA Organization Requirement component allows you to customize the flow around an organization admin enabling 2FA for their organization. Check out the documentation here for more information.
Update 2FA Organization Requirement
Require 2FA for all organization members
Require 2FA By
Save Security Settings
Shadcn Installation
Install this component from our shadcn registry.
npx shadcn@latest add https://components.propelauth.com/r/update-org-2fa-requirement.json
Reference APIs
These are the APIs that are used by the above component. You can use these APIs directly in your own code.
fetchOrgSettings
Fetches the provided org's settings and information, such as org name, SAML status, 2FA requirements, and more.
Arguments
- Name
org_id*Type string Description The ID of the org.
Success Response
- Name
org_nameType string Description The name of the organization. - Name
user_can_edit_org_accessType boolean Description Returns true if the user has the necessary permissions to update the org settings. - Name
user_can_update_metadataType boolean Description Returns true if the user has the necessary permissions to update the org metadata. - Name
autojoin_by_domainType boolean Description If a domain is set for the org, new users can join the org if their domain matches the org's domain. - Name
restrict_to_domainType boolean Description If a domain is set for the org, only allow users with that domain to join. - Name
require_2fa_byType string | null Description The date by which 2FA is required for the org. If null, 2FA is not required. - Name
existing_domainType string | null Description The org's current domain, if one is set. - Name
current_user_domainType string Description The domain of the current user. - Name
current_user_domain_is_personalType boolean Description Returns true if the current user's domain is personal (e.g. gmail.com). - Name
can_setup_samlType boolean Description Returns true if the org can set up SAML. - Name
is_saml_enabledType boolean Description Returns true if the org has SAML enabled. - Name
is_saml_in_test_modeType boolean Description Returns true if the org has SAML in test mode. - Name
can_setup_scimType boolean Description Returns true if the org can set up SCIM. - Name
is_scim_enabledType boolean Description Returns true if the org has SCIM enabled.
Response Functions
The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.
- Name
successDescription Successful request. - Name
orgsNotEnabledDescription Orgs are not enabled in the PropelAuth dashboard. - Name
orgNotFoundDescription The provided organization was not found. - Name
forbiddenDescription The user does not have permission to view the organization settings. - Name
unauthorizedDescription The user is not logged in. - Name
unexpectedOrUnhandledDescription An unexpected error occurred.
Request
const { fetchOrgSettings } = useAuthFrontendApis()
const response = await fetchOrgSettings('1189c444-8a2d-4c41-8b4b-ae43ce79a492')
await response.handle({
success: (data) => {
console.log(data)
},
orgsNotEnabled() {
console.log('Organizations are not enabled.')
},
orgNotFound() {
console.log('Organization not found.')
},
forbidden() {
console.log("You do not have permission to view this organization's settings.")
},
unexpectedOrUnhandled() {
console.log('An unexpected error occurred.')
},
})
Successful Response
{
"user_can_update_metadata": true,
"user_can_edit_org_access": true,
"org_name": "Acme Inc",
"autojoin_by_domain": true,
"restrict_to_domain": true,
"existing_domain": "acmeinc.com",
"current_user_domain": "acmeinc.com",
"current_user_domain_is_personal": false,
"require_2fa_by": "1732645813",
"can_setup_saml": true,
"is_saml_enabled": false,
"is_saml_in_test_mode": false,
"can_setup_scim": false,
"is_scim_enabled": false
}
updateOrgSettings
Updates the settings for an organization.
Arguments
- Name
org_id*Type string Description The ID of the org to be updated. - Name
nameType string Description The new name of the org. - Name
allow_users_to_join_by_domainType boolean Description If a domain is set for the org, new users can join the org if their domain matches the org's domain. - Name
restrict_invites_by_domainType boolean Description If a domain is set for the org, only allow users with that domain to join. - Name
require_2fa_byType date Description If requiring 2FA for an org, the date you want to enforce it by.
Response Functions
The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.
- Name
successDescription Successful request. - Name
orgsNotEnabledDescription Organizations are not enabled in this project. - Name
orgNotFoundDescription The provided orgId was not found - Name
forbiddenDescription The user does not have permission to edit the org. - Name
badRequestDescription Incorrect arguments given. - Name
unauthorizedDescription The user is not logged in. - Name
unexpectedOrUnhandledDescription An unexpected error occurred.
Request
const { updateOrgSettings } = useAuthFrontendApis()
const response = await updateOrgSettings({
org_id: '1189c444-8a2d-4c41-8b4b-ae43ce79a492',
name: 'Acme Inc',
allow_users_to_join_by_domain: true,
restrict_invites_by_domain: true,
require_2fa_by: '2025-01-16T00:00:00.000Z',
})
response.handle({
success() {
console.log('Updated org settings successfully.')
},
badRequest(error) {
for (const [field, fieldErrorMessage] of Object.entries(error.user_facing_errors)) {
console.log('Error: "' + fieldErrorMessage + '" for field: "' + field + '"')
}
},
orgsNotEnabled(error) {
console.log('Org not enabled', error)
},
orgNotFound(error) {
console.log('Org not found', error)
},
forbidden(error) {
console.log('Forbidden', error)
},
unexpectedOrUnhandled(error) {
console.log('Unexpected or unhandled error', error)
},
})
Successful Response
{}