From 4283bc19bff76b74d859230cd0ca54ab8f70a73e Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Thu, 18 Feb 2016 19:00:38 +0100 Subject: Improved confirm_account view. --- src/web/views/user.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/web/views/user.py b/src/web/views/user.py index 0f9fe612..57153003 100644 --- a/src/web/views/user.py +++ b/src/web/views/user.py @@ -109,14 +109,16 @@ def confirm_account(token=None): Confirm the account of a user. """ user_contr = UserController() + user, email = None, None if token != "": email = confirm_token(token, expiration=3600) + if email: user = user_contr.read(email=email).first() - if user is not None: - user_contr.update({'id': user.id}, {'enabled': True}) - flash(gettext('Your account has been confirmed.'), 'success') - else: - flash(gettext('Impossible to confirm this account.'), 'danger') + if user is not None: + user_contr.update({'id': user.id}, {'enabled': True}) + flash(gettext('Your account has been confirmed.'), 'success') + else: + flash(gettext('Impossible to confirm this account.'), 'danger') return redirect(url_for('login')) -- cgit