formio / cli

The Form.io command line interface.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error Upon Bind

ArthurAllshire opened this issue · comments

Environment

Please provide as many details as you can: Trying to run the bind command as documented in the remote middleware docs.

  • Hosting type
    • Form.io
    • Local deployment
      • Version:
  • Formio.js version:
  • Frontend framework: N/A
  • Browser: N/A
  • Browser version: N/A

Steps to Reproduce

  1. Run the formio CLI bind command: formio bind POST https://project-slug.form.io/volunteerform/submission

Observed behavior

I am asks to authenticate and this works fine, however I then get an: Error: Unexpected server response: 400, and the remote middleware does not run. I also tried with simply https://project-slug.form.io/volunteerform (omitting the /submission).

@ArthurAllshire

We have deprecated our "Remote Middleware" feature and have since replaced it with Blocking Webhooks. You can accomplish the same thing by setting up a webhook, check the checkbox that says "Wait for webhook response" and then send that to a webhook receiver. We have an example of a webhook receiver @ https://github.com/formio/formio-webhook-receiver. There are several example that show how you can maniupulate the validation response @ https://github.com/formio/formio-webhook-receiver/blob/master/validation/server.js as well as manipulate the data payload at runtime. This also works in AWS Lambda which is something that our previous remote middleware was not able to accomplish.

Thanks @wag110894 . Is there any documentation about how you perform the manipulation of the data payload? That example appears to show only validation?

Can you help us understand what it is you are trying to do? If you have a webhook action on your form you can use the payload transform function to change the payload before it is sent to your rest api.

Sure. I am trying to implement a passwordless login system (as described here). I want to check if the user exists in the associated resource before sending the email containing the login link / token (we want to allow only a pre-approved list of emails in a resource to login to our system). So at the moment the way I was doing it is by querying the email within the resource in the webhook receiver (using the REST apis). I can do this, but even sending say a 401 status code the subsequent actions (emailing) get triggered using the associated webhook. So I was thinking of adding a status field to the submission in the webhook reciever to indicate whether the user exists in the database and conditionally sending the email based on that - is there a better way of doing this?

You can use the "exists" endpoint on the User resource to see if a user exists or not. https://apidocs.form.io/?version=latest#bf453942-57fa-b22d-54e0-ab403c3b26a2

Yup, I am able to query that in the API docs. The bit that I am having trouble with is how to make my email action send conditional upon the email being sent to existing in another resource?

Doing a bit more research, it seems that the easiest way to achieve what I want is to send the email from the webhook receiver without using an action and generate the token on that side myself (as here) - does this seem correct?

We're currently addressing a backlog of GitHub issues. Closing this thread as it is outdated. Please re-open if it is still relevant. Thank you for your contribution!