Answered

Restrict submit of form to a list of e-mail addresses

  • 2 February 2021
  • 7 replies
  • 1486 views

Is it possible to allow submission of a form only to a list of known e-mail addresses? I could set up a logic jump but the question is can i as condition set a “list” of hundreds of e-mails? Also the logic jump would need a message as target (like “sorry this form is restricted to a list of e-mail addresses). If its not possible with logic jumps any other way?

icon

Best answer by Francois Grenier 4 February 2021, 01:52

View original

7 replies

Userlevel 7
Badge +5

Welcome to the community, @roots-of-impact !

 

https://gph.is/g/Z7gGnBB

 

If you only have a few email addresses, you could setup logic jumps for this. Though for hundreds, the logic jump solution would be a bit time consuming!

Instead, we have a tech-solution similar to what you’re looking for here that may work for you involving cookies. Hopefully this helps a bit!

@Liz thanks for that. we use webhooks so that could be away. the webhook triggered on new response could determine if the email is allowed to use the form and if not delete the response. but then there is no feedback for the user so not really a good solution. 

The cookie solution does not apply in our case since we want to forbid users not on the list to fill out the form.

I suppose a beforeSubmit https://developer.typeform.com/embed/onsubmit-callback/ hook does not exist?

Userlevel 7
Badge +5

Hi @roots-of-impact while there isn’t any in-form feedback to test if the email is one of the ones on a list of emails, this is an interesting case for @picsoung and @Francois (Typeform) to know about for any future integrations. 

Userlevel 2

mmm interesting question @roots-of-impact . As a brute-force approach, I would explore the logic jump route, but adding a hundreds of emails is a bit dreadful. Thankfully, this can also be done programmatically fairly easily using our API:

  1. add a couple of addresses in the logic builder
  2. get your form’s JSON description
  3. find the logic section where your list of email addresses is
  4. massage the JSON payload to add the logic for each additional email address
  5. update the form with the new payload from step 4. 

in a simple form example, the logic section of the form payload (expecting to filter out emails as hidden fields) would look like this:

"logic": [
{
"type": "hidden",
"actions": [
{
"action": "jump",
"details": {
"to": {
"type": "field",
"value": "my_perfectly_readable_reference"
}
},
"condition": {
"op": "or",
"vars": [
{
"op": "equal",
"vars": [
{
"type": "hidden",
"value": "email"
},
{
"type": "constant",
"value": "user1@user.com"
}
]
},
{
"op": "equal",
"vars": [
{
"type": "hidden",
"value": "email"
},
{
"type": "constant",
"value": "user2@user.com"
}
]
}
]
}
},
{
"action": "jump",
"details": {
"to": {
"type": "field",
"value": "my_other_question_reference"
}
},
"condition": {
"op": "always",
"vars": []
}
}
]
}
],

You “just” have to repeat an “op”: “equal” block for each new email address with a quick script. 

A more polished solution @picsoung wrote about some time ago is using Serverless to prevent users from taking a survey multiple times. The concept can be reapplied to your case.

Let us know what you try and how it goes.

Userlevel 7
Badge +6

@Francois (Typeform) - two upvotes from me.. 

Userlevel 7
Badge +5

The workaround suggested by @Francois (Typeform) should work great. There is no theoretical limitation on logic jumps, but it can get complicated if you are dealing with hundreds of conditions. So keep in mind that this solution would only work until a certain point.

Unfortunately, we don’t offer any `beforeSubmit` callback as you suggested. It would mean the embed code has access to the responses filled in the form. It might then become a security issue, because anybody could embed your form and pretend it’s you. So I would not recommend this option.

@picsoung well the typeform is connected to adminstration dashboard in our project there i could create the logic jumps via the create api when the dashboard user uploads a csv email whitelist. question is can i use up to a thousand “or” logic jumps for each email? it would be greate if it could work with email domain wildcard (regex) or “contains”. but in the end we may stick to the post webhook workflow. seems more straightforward 

Reply