Add message to confirm account for unconfirmed users

This commit is contained in:
Stephan Porada 2019-07-09 10:09:35 +02:00
parent 68e1607af3
commit 1ec93fa7d6
3 changed files with 46 additions and 0 deletions

View File

@ -62,6 +62,32 @@ def confirm(token):
return redirect(url_for('main.index')) return redirect(url_for('main.index'))
@auth.before_app_request
def before_request():
if current_user.is_authenticated \
and not current_user.confirmed \
and request.blueprint != 'auth' \
and request.blueprint != 'static':
return redirect(url_for('auth.unconfirmed'))
@auth.route('/unconfirmed')
def unconfirmed():
if current_user.is_anonymous or current_user.confirmed:
return redirect(url_for('main.index'))
return render_template('auth/unconfirmed.html.j2')
@auth.route('/confirm')
@login_required
def resend_confirmation():
token = current_user.generate_confirmation_token()
send_email(current_user.email, 'Confirm Your Account', 'auth/email/confirm',
user=current_user, token=token)
flash('A new confirmation email has benn sent to you by email.')
return redirect(url_for('maind.index'))
@auth.route('/reset', methods=['GET', 'POST']) @auth.route('/reset', methods=['GET', 'POST'])
def password_reset_request(): def password_reset_request():
if not current_user.is_anonymous: if not current_user.is_anonymous:

View File

@ -0,0 +1,20 @@
{% extends "base.html.j2" %}
{% block title %}Opaque - Confirm your account{% endblock %}
{% block page_content %}
<div class="page-header">
<h1>
Hello, {{ current_user.username }}!
</h1>
<h3>You have not confirmed your account yet.</h3>
<p>
Before you can access this site you need to confirm your account.
Check your inbox, you should have received an email with a confirmation link.
</p>
<p>
Need another confirmation email?
<a href="{{ url_for('auth.resend_confirmation') }}">Click here</a>
</p>
</div>
{% endblock %}

Binary file not shown.