Do not use objects after deleting them, fixes #112

master
Pierre Jaury 8 years ago
parent e73b12ba55
commit 373998ea99

@ -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))

@ -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})

Loading…
Cancel
Save