# Form button, trigger action instead of flow?

**URL:** <https://community.auth0.com/t/form-button-trigger-action-instead-of-flow/194082>\
**Category:** Get Help\
**Tags:** new-universal-login-experience, login-experience\
**Created:** [November 5, 2025, 4:13am UTC](https://community.auth0.com/t/form-button-trigger-action-instead-of-flow/194082 "2025-11-05T04:13:47Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![kurt.dunn](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/kurt.dunn/32/72021_2.png) [@kurt.dunn](https://community.auth0.com/u/kurt.dunn)\
**Post date:** [November 11, 2025, 1:01am UTC](https://community.auth0.com/t/form-button-trigger-action-instead-of-flow/194082/7 "2025-11-11T01:01:55Z")

</div>

Hi again @teodor.andrei

That was super helpful! Though i made some changes to get it to work.

I do have 1 final question below.

```auto

/**
 * Initial trigger - render the form
 */
exports.onExecutePostLogin = async (event, api) => {
  const formId = event.secrets.FORM_ID;
  
  // Skip if already validated
  if (event.user.app_metadata?.verified) {
    return;
  }
  
  // Show the form
  api.prompt.render(formId);
};

/**
 * Form submission handler - validate and continue or show error
 */
exports.onContinuePostLogin = async (event, api) => {
  const config = {
    apiBaseUrl: event.secrets.API_BASE_URL,
    username: event.secrets.API_USERNAME,
    password: event.secrets.API_PASSWORD,
    formId: event.secrets.FORM_ID
  };

  // Get form data
  const userInput = event.prompt?.fields?.user_input;

  if (!userInput) {
    api.prompt.render(config.formId, {
      vars: { errmsg: 'Input is required.' }
    });
    return;
  }

  try {
    // Step 1: Get API token
    const authResponse = await fetch(`${config.apiBaseUrl}/auth`, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        username: config.username,
        password: config.password
      })
    });

    if (!authResponse.ok) {
      throw new Error('Authentication failed');
    }

    const { token } = await authResponse.json();

    // Step 2: Validate user input with API
    const validationResponse = await fetch(`${config.apiBaseUrl}/validate`, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        'Authorization': `Bearer ${token}`
      },
      body: JSON.stringify({
        email: event.user.email,
        input: userInput
      })
    });

    const result = await validationResponse.json();

    // Step 3: Success - mark as verified and continue
    if (validationResponse.ok && result.valid) {
      api.user.setAppMetadata('verified', true);
      return; // Continue with login
    }

    // Step 4: Failed - re-render form with error
    api.prompt.render(config.formId, {
      vars: { errmsg: result.error || 'Validation failed. Please try again.' }
    });

  } catch (error) {
    // Error handling - re-render form
    api.prompt.render(config.formId, {
      vars: { errmsg: 'Unable to validate. Please try again.' }
    });
  }
};

```

Obviously when the user clicks continue, the action repeats until the logic is satisfied.  
But, Id like to be able to offer a second button to skip all the logic and then contine through the rest of the actions.

 ![Screenshot 2025-11-11 at 11.57.46 am](https://global.discourse-cdn.com/auth0/original/3X/c/5/c51bae0cc717e3bafbd52e6d979e5353c9fd97f6.png)

In the action, can we do something like this and just return?

```auto
  // Check if user clicked "Skip" button
  if (event.prompt.action === 'skip') {
    console.log(`PIVOTAL_VALIDATION_SKIP: User ${event.user.email} clicked Skip button`);
    // Allow login without validation
    return;
  }

```

Thanks again, for your help!

---

_[View the full topic](https://community.auth0.com/t/form-button-trigger-action-instead-of-flow/194082)._
