2210: Add input validation for domain creation r=mergify[bot] a=0pc0deFR

## What type of PR?

bug-fix

## What does this PR do?

This patch add the input validation for domain creation.

### Related issue(s)
- Mention an issue like: #1817
- Auto close an issue like: closes #1817


Co-authored-by: Kevin Falcoz <0pc0defr@gmail.com>
Co-authored-by: Dimitri Huisman <diman@huisman.xyz>
master
bors[bot] 3 years ago committed by GitHub
commit 0b25854de0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2,6 +2,7 @@ from mailu import models
from mailu.ui import ui, forms, access
from flask import current_app as app
import validators
import flask
import flask_login
import wtforms_components
@ -18,6 +19,7 @@ def domain_list():
def domain_create():
form = forms.DomainForm()
if form.validate_on_submit():
if validators.domain(form.name.data):
conflicting_domain = models.Domain.query.get(form.name.data)
conflicting_alternative = models.Alternative.query.get(form.name.data)
conflicting_relay = models.Relay.query.get(form.name.data)
@ -30,6 +32,8 @@ def domain_create():
models.db.session.commit()
flask.flash('Domain %s created' % domain)
return flask.redirect(flask.url_for('.domain_list'))
else:
flask.flash('Domain %s is invalid' % form.name.data, 'error')
return flask.render_template('domain/create.html', form=form)

@ -0,0 +1 @@
Add input validation for domain creation
Loading…
Cancel
Save