mirror of
https://github.com/Mailu/Mailu.git
synced 2025-01-18 03:21:36 +02:00
Merge #2210
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>
This commit is contained in:
commit
0b25854de0
@ -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)
|
||||
|
||||
|
||||
|
1
towncrier/newsfragments/2210.bugfix
Normal file
1
towncrier/newsfragments/2210.bugfix
Normal file
@ -0,0 +1 @@
|
||||
Add input validation for domain creation
|
Loading…
Reference in New Issue
Block a user