submission: warn when an anonymous form is created if nameid is unknown (#45758)
This commit is contained in:
parent
59a4fcb485
commit
bffc38f86c
|
@ -1310,6 +1310,17 @@ def test_backoffice_submission_with_nameid_and_channel(pub, local_user):
|
|||
assert formdata.submission_channel == 'mail'
|
||||
assert formdata.status == 'wf-new'
|
||||
|
||||
# target user is unknown
|
||||
app = login(get_app(pub))
|
||||
resp = app.get('/backoffice/submission/form-title/?NameID=UNKNOWN_NAMEID')
|
||||
assert resp.location.startswith('http://example.net/backoffice/submission/form-title/')
|
||||
formdata_no = resp.location.split('/')[-2]
|
||||
formdata = formdef.data_class().get(formdata_no)
|
||||
assert not formdata.user_id
|
||||
resp = resp.follow() # redirect to created draft
|
||||
resp = resp.follow() # redirect to ?mt=
|
||||
assert 'The target user was not found, this form is anonymous.' in resp.text
|
||||
|
||||
|
||||
def test_backoffice_submission_only_one_check(pub, local_user):
|
||||
user = create_user(pub)
|
||||
|
|
|
@ -133,6 +133,11 @@ class FormFillPage(PublicFormFillPage):
|
|||
users = list(get_publisher().user_class.get_users_with_name_identifier(name_id))
|
||||
if users:
|
||||
formdata.user_id = users[0].id
|
||||
else:
|
||||
get_session().message = (
|
||||
'warning',
|
||||
_('The target user was not found, this form is anonymous.'),
|
||||
)
|
||||
if return_url:
|
||||
formdata.submission_context['return_url'] = return_url
|
||||
if submission_channel == 'phone' and caller:
|
||||
|
|
Loading…
Reference in New Issue