1
0
mirror of https://github.com/Mailu/Mailu.git synced 2024-12-14 10:53:30 +02:00

Do not use objects after deleting them, fixes #112

This commit is contained in:
Pierre Jaury 2016-11-12 15:47:48 +01:00
parent e73b12ba55
commit 373998ea99
2 changed files with 4 additions and 2 deletions

View File

@ -56,8 +56,9 @@ def alias_edit(alias):
@access.confirmation_required("delete {alias}")
def alias_delete(alias):
alias = models.Alias.query.get(alias) or flask.abort(404)
domain = alias.domain
db.session.delete(alias)
db.session.commit()
flask.flash('Alias %s deleted' % alias)
return flask.redirect(
flask.url_for('.alias_list', domain_name=alias.domain.name))
flask.url_for('.alias_list', domain_name=domain.name))

View File

@ -60,11 +60,12 @@ def user_edit(user_email):
@access.confirmation_required("delete {user_email}")
def user_delete(user_email):
user = models.User.query.get(user_email) or flask.abort(404)
domain = user.domain
db.session.delete(user)
db.session.commit()
flask.flash('User %s deleted' % user)
return flask.redirect(
flask.url_for('.user_list', domain_name=user.domain.name))
flask.url_for('.user_list', domain_name=domain.name))
@app.route('/user/settings', methods=['GET', 'POST'], defaults={'user_email': None})