Directus icon

Directus

Consume Directus API

Overview

The Directus n8n node, when configured with the Users resource and the Enable 2FA operation, enables two-factor authentication (2FA) for the currently authenticated user in a Directus instance. This is typically used after generating a 2FA secret and verifying it with a one-time password (OTP). The node sends the required credentials to the Directus API endpoint to activate 2FA on the user's account.

Common scenarios:

  • Enforcing additional security for user accounts by enabling 2FA.
  • Automating onboarding workflows where users are required to set up 2FA.
  • Integrating with other systems that require programmatic control over user security settings.

Practical example:
After a user generates a 2FA secret using the "Generate 2FA" operation and sets up their authenticator app, this operation can be used to enable 2FA by providing the secret and a valid OTP from the app.


Properties

Name Type Meaning
Secret String The TFA (Two-Factor Authentication) secret generated previously (from tfa/generate).
OTP String The One-Time Password generated using the secret, used to verify correct 2FA setup.

Output

The output will be a JSON object containing the response from the Directus API after attempting to enable 2FA. The structure of the json field typically reflects the Directus API's response, which may include confirmation of success or details about any errors encountered.

Example output:

{
  "json": {
    // Success or error information as returned by Directus
  }
}

Dependencies

  • Directus API: Requires access to a running Directus instance.
  • API Credentials: The node must be configured with valid Directus API credentials (directusApi).
  • User Context: The operation acts on the currently authenticated user.

Troubleshooting

Common issues:

  • Invalid Secret or OTP: If the provided secret or OTP is incorrect, the API will return an error indicating invalid credentials.
  • 2FA Already Enabled: Attempting to enable 2FA when it's already active may result in an error.
  • Missing Credentials: If the node is not properly configured with Directus API credentials, requests will fail.

Error messages and resolutions:

  • "Invalid OTP": Ensure the OTP is generated from the correct secret and is current.
  • "Secret not found": Make sure you have generated a 2FA secret before enabling 2FA.
  • "Authentication failed": Check your Directus API credentials and session.

Links and References


Discussion