Skip to content

Commit

Permalink
Fix sending activation emails
Browse files Browse the repository at this point in the history
  • Loading branch information
sh4nks committed Sep 28, 2016
1 parent c929ec5 commit c589683
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions flaskbb/auth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 149,13 @@ def register():
user = form.save()

if flaskbb_config["ACTIVATE_ACCOUNT"]:
# Any call to an expired model requires a database hit, so
# accessing user.id would cause an DetachedInstanceError.
# This happens because the `user`'s session does no longer exist.
# So we just fire up another query to make sure that the session
# for the newly created user is fresh.
# PS: `db.session.merge(user)` did not work for me.
user = User.query.filter_by(email=user.email).first()
send_activation_token.delay(user)
flash(_("An account activation email has been sent to %(email)s",
email=user.email), "success")
Expand Down

0 comments on commit c589683

Please sign in to comment.