From 1ec93fa7d6137499a72239f704e7412f9eef8547 Mon Sep 17 00:00:00 2001 From: Stephan Porada <sporada@uni-bielefeld.de> Date: Tue, 9 Jul 2019 10:09:35 +0200 Subject: [PATCH] Add message to confirm account for unconfirmed users --- app/auth/views.py | 26 +++++++++++++++++++++++++ app/templates/auth/unconfirmed.html.j2 | 20 +++++++++++++++++++ data_dev.sqlite | Bin 32768 -> 32768 bytes 3 files changed, 46 insertions(+) create mode 100644 app/templates/auth/unconfirmed.html.j2 diff --git a/app/auth/views.py b/app/auth/views.py index e4595f37..abb1ccff 100644 --- a/app/auth/views.py +++ b/app/auth/views.py @@ -62,6 +62,32 @@ def confirm(token): 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']) def password_reset_request(): if not current_user.is_anonymous: diff --git a/app/templates/auth/unconfirmed.html.j2 b/app/templates/auth/unconfirmed.html.j2 new file mode 100644 index 00000000..78ac1510 --- /dev/null +++ b/app/templates/auth/unconfirmed.html.j2 @@ -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 %} diff --git a/data_dev.sqlite b/data_dev.sqlite index bf94d7cea40518bb8971abc2d80a79d41eb18807..78cdddd233acf07a4b2c9fae158d207d54f05fa3 100644 GIT binary patch delta 250 zcmZo@U}|V!njp<6IZ?)$QF3F#5`P6gj^7OYWqkkn+W7c+r}4`2Oyv>dp3N=A)x*Wj zS<mr%W8-xWwMIrh4hB<chDJ}$#Nv|FqRa}1lA^@o4BgyRz2y8{M~K+ujj^JhjyX|9 zVJ78aD#j+JDJf~GmPv^g=H_WBrm3lk<|d{l1_nk3#zrO<28oFVX_jV*CZ+~S#%3vr zspf{pCP^j+NrovYhG_;yX`AaKTiMw7_;xe!?cU6hu#rzvg4vW2oArE~ujCmpvhne! ZGVrHv<|v5f=iz3SW`w$mZ*pOMKLAt=O3(lR delta 94 zcmZo@U}|V!njp<6K2gS*QG8><5`Q^f&Uyy^GQR(OZG8N^(|Bchrt*k!&*qlm>fz$% ztl!ue%elEevXza6m+uP0X0C*dd=n=~Z@!Xez{tYOU&yeTt00<xVgTRd!uoyy&qNzw -- GitLab