Actions109
- Collections Actions
- Activity Actions
- Assets Actions
- Authentication Actions
- Extensions Actions
- Fields Actions
- Files Actions
- Folders Actions
- Items Actions
- Permissions Actions
- Presets Actions
- Relations Actions
- Revisions Actions
- Roles Actions
- Settings Actions
- Users Actions
- Utilities Actions
- Webhooks Actions
Overview
The Directus (DrWade) n8n node for the resource Users and operation Enable 2FA allows you to enable two-factor authentication (2FA) for the currently authenticated user in a Directus instance. This is typically used after generating a TFA secret and verifying it with a one-time password (OTP), providing an extra layer of security for user accounts.
Common scenarios:
- Enabling 2FA for users as part of an onboarding or security-hardening workflow.
- Automating the process of securing user accounts via n8n flows.
- Integrating Directus user management with other systems that require 2FA activation.
Practical example:
After a user generates a TFA secret using the "Generate 2FA" operation, this node can be used to confirm and activate 2FA by submitting the secret and a valid OTP generated from it.
Properties
| Name | Type | Meaning |
|---|---|---|
| Secret | String | The TFA secret previously generated (e.g., from the "generate2FA" operation). |
| OTP | String | A one-time password generated using the provided secret, to verify correct TFA setup. |
Output
- The output will be a JSON object containing the response from the Directus API after attempting to enable 2FA.
- On success, the
jsonfield will contain the API's response data, which may include confirmation details or status. - On failure, if "Continue On Fail" is enabled, the
jsonfield will contain anerrorproperty with the error message.
Example output (success):
{
"json": {
// ...API response fields, e.g.,
"status": "success"
}
}
Example output (failure):
{
"json": {
"error": "Invalid OTP code"
}
}
Dependencies
- Directus API: Requires access to a running Directus instance.
- API Credentials: The node requires valid Directus API credentials configured in n8n under the name
directusApi.
Troubleshooting
Common issues:
- Invalid Secret or OTP: If the secret or OTP is incorrect, the API will return an error (e.g., "Invalid OTP code").
- Resolution: Ensure the secret matches the one generated for the user and the OTP is freshly generated from a compatible authenticator app.
- Missing Credentials: If API credentials are not set up or are invalid, the node will fail to connect to Directus.
- Resolution: Check and update the Directus API credentials in n8n.
- User Not Authenticated: The operation works for the current user; ensure the workflow runs in the context of an authenticated user.
Error messages:
"Invalid OTP code": The OTP does not match the expected value for the given secret."Missing required parameter: secret"or"otp": One or both required fields were not provided.
Links and References
- Directus Documentation – Authentication
- Directus API Reference – Users TFA
- n8n Documentation – Credentials
- Two-Factor Authentication (Wikipedia)