|
|
|
@ -28,6 +28,11 @@ def user_create(domain_name):
|
|
|
|
|
form.quota_bytes.validators = [
|
|
|
|
|
wtforms.validators.NumberRange(max=domain.max_quota_bytes)]
|
|
|
|
|
if form.validate_on_submit():
|
|
|
|
|
breaches = int(form.pwned.data)
|
|
|
|
|
if breaches > 0:
|
|
|
|
|
flask.flash(f"This password appears in {breaches} data breaches! Please change it.", "error")
|
|
|
|
|
return flask.render_template('user/create.html',
|
|
|
|
|
domain=domain, form=form)
|
|
|
|
|
if domain.has_email(form.localpart.data):
|
|
|
|
|
flask.flash('Email is already used', 'error')
|
|
|
|
|
else:
|
|
|
|
@ -60,6 +65,11 @@ def user_edit(user_email):
|
|
|
|
|
form.quota_bytes.validators = [
|
|
|
|
|
wtforms.validators.NumberRange(max=max_quota_bytes)]
|
|
|
|
|
if form.validate_on_submit():
|
|
|
|
|
breaches = int(form.pwned.data)
|
|
|
|
|
if breaches > 0:
|
|
|
|
|
flask.flash(f"This password appears in {breaches} data breaches! Please change it.", "error")
|
|
|
|
|
return flask.render_template('user/edit.html', form=form, user=user,
|
|
|
|
|
domain=user.domain, max_quota_bytes=max_quota_bytes)
|
|
|
|
|
form.populate_obj(user)
|
|
|
|
|
if form.pw.data:
|
|
|
|
|
user.set_password(form.pw.data)
|
|
|
|
@ -119,6 +129,10 @@ def user_password(user_email):
|
|
|
|
|
if form.pw.data != form.pw2.data:
|
|
|
|
|
flask.flash('Passwords do not match', 'error')
|
|
|
|
|
else:
|
|
|
|
|
breaches = int(form.pwned.data)
|
|
|
|
|
if breaches > 0:
|
|
|
|
|
flask.flash(f"This password appears in {breaches} data breaches! Please change it.", "error")
|
|
|
|
|
return flask.render_template('user/password.html', form=form, user=user)
|
|
|
|
|
flask.session.regenerate()
|
|
|
|
|
user.set_password(form.pw.data)
|
|
|
|
|
models.db.session.commit()
|
|
|
|
@ -170,6 +184,10 @@ def user_signup(domain_name=None):
|
|
|
|
|
if domain.has_email(form.localpart.data) or models.Alias.resolve(form.localpart.data, domain_name):
|
|
|
|
|
flask.flash('Email is already used', 'error')
|
|
|
|
|
else:
|
|
|
|
|
breaches = int(form.pwned.data)
|
|
|
|
|
if breaches > 0:
|
|
|
|
|
flask.flash(f"This password appears in {breaches} data breaches! Please change it.", "error")
|
|
|
|
|
return flask.render_template('user/signup.html', domain=domain, form=form)
|
|
|
|
|
flask.session.regenerate()
|
|
|
|
|
user = models.User(domain=domain)
|
|
|
|
|
form.populate_obj(user)
|
|
|
|
|