how email verification works python

Solutions on MaxInterview for how email verification works python by the best coders in the world

showing results for - "how email verification works python"
Jona
06 Feb 2019
1@user_blueprint.route('/confirm/<token>')
2@login_required
3def confirm_email(token):
4    try:
5        email = confirm_token(token)
6    except:
7        flash('The confirmation link is invalid or has expired.', 'danger')
8    user = User.query.filter_by(email=email).first_or_404()
9    if user.confirmed:
10        flash('Account already confirmed. Please login.', 'success')
11    else:
12        user.confirmed = True
13        user.confirmed_on = datetime.datetime.now()
14        db.session.add(user)
15        db.session.commit()
16        flash('You have confirmed your account. Thanks!', 'success')
17    return redirect(url_for('main.home'))
18