Previous question on this issue is here. CSRF token continues to fail on Flask-WTF forms. Config and details of setup are in the link.
What I've now discovered is that on my template, to which I pass two forms in the view, the csrf_token on each form isn't unique. I don't quite understand why? The CSRF tokens should be unique per form right?
I checked the tokens in Chrome, and they're identical - both included in the bottom block of code.
<form method="post" class="mt-4" id="form_1">
{{ form1.csrf_token }}
<div class="form-group"
{{ form1.form_field1(class_='form-control', id='foo', type='text',
placeholder='Enter your data') }}
</div>
<div class="form-group">
{{ form1.form_field2(class_='form-control', id='bar',
type='text', placeholder='More data please') }}
</div>
{{ form1.submit(class_='btn btn-lg btn-info btn-block', form='form_1' ) }}
<!-- <button form="form_1" type="submit"-->
<!-- class="btn btn-lg btn-info btn-block">-->
<!-- <i class="fa fa-lock fa-lg"></i> -->
<!-- </button>-->
</form>
<form class="mt-3" method="post" id="form_2">
<div class="form-group input-group">
{{ form2.csrf_token }}
{% if current_user.has_value() %}
{{form2.field(type='checkbox', checked=1)}}
{% else %}
{{ form2.field(type='checkbox') }}
{% endif %}
{{ form2.update(type='submit', class_='btn btn-light input-group-append') }}
</div>
</form>
<form method="post" class="mt-4" id="form_1">
<input id="csrf_token" name="csrf_token" type="hidden" value="ImM5OWI2NTJiY2RhOGJkNjlkYjFkYzliM2JkMDM4N2JmODQwMDU1YWQi.XiAz0A.7r1lBMq-tO0wrukerCfIFgXwK9M">
.....
<form class="mt-3" method="post" id="form_2">
<div class="form-group input-group">
<input id="csrf_token" name="csrf_token" type="hidden" value="ImM5OWI2NTJiY2RhOGJkNjlkYjFkYzliM2JkMDM4N2JmODQwMDU1YWQi.XiAz0A.7r1lBMq-tO0wrukerCfIFgXwK9M">