don't leak information about other users aliases and mailboxes

This commit is contained in:
j3d1 2021-10-28 00:29:17 +02:00
parent 252982d038
commit 5fce1fb288

View file

@ -109,6 +109,10 @@ def edit_mailbox(request, mailbox_id):
if form.is_valid() and form.cleaned_data['domain'] in domains:
form.save()
return HttpResponseRedirect('/mailboxes/')
else:
if not form.cleaned_data['domain'] in domains:
form.errors.clear()
form.add_error(None, "You don't own this domain")
except IntegrityError as e:
form.add_error(None, e)
@ -129,6 +133,10 @@ def new_mailbox(request):
if form.is_valid() and form.cleaned_data['domain'] in domains:
form.save()
return HttpResponseRedirect('/mailboxes/')
else:
if not form.cleaned_data['domain'] in domains:
form.errors.clear()
form.add_error(None, "You don't own this domain")
except IntegrityError as e:
form.add_error(None, e)
@ -153,6 +161,10 @@ def edit_alias(request, alias_id):
if form.is_valid() and form.cleaned_data['source_domain'] in domains:
form.save()
return HttpResponseRedirect('/aliases/')
else:
if not form.cleaned_data['source_domain'] in domains:
form.errors.clear()
form.add_error(None, "You don't own this domain")
except IntegrityError as e:
form.add_error(None, e)
@ -173,6 +185,10 @@ def new_alias(request):
if form.is_valid() and form.cleaned_data['source_domain'] in domains:
form.save()
return HttpResponseRedirect('/aliases/')
else:
if not form.cleaned_data['source_domain'] in domains:
form.errors.clear()
form.add_error(None, "You don't own this domain")
except IntegrityError as e:
form.add_error(None, e)