mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-07-01 10:20:34 +00:00
Update Terms of Use Modal and fix message flashing.
This commit is contained in:
@ -19,6 +19,7 @@ def before_request():
|
||||
and request.endpoint
|
||||
and request.blueprint != 'auth'
|
||||
and request.endpoint != 'static'
|
||||
and request.endpoint != 'main.accept_terms_of_use'
|
||||
):
|
||||
return redirect(url_for('auth.unconfirmed'))
|
||||
|
||||
|
@ -1,8 +1,9 @@
|
||||
from flask import flash, redirect, render_template, url_for
|
||||
from flask import abort, flash, jsonify, redirect, render_template, url_for
|
||||
from flask_login import current_user, login_required, login_user
|
||||
from app.blueprints.auth.forms import LoginForm
|
||||
from app.models import Corpus, User
|
||||
from . import bp
|
||||
from app import db
|
||||
|
||||
|
||||
@bp.route('/', methods=['GET', 'POST'])
|
||||
@ -72,6 +73,16 @@ def terms_of_use():
|
||||
)
|
||||
|
||||
|
||||
@bp.route('/accept-terms-of-use', methods=['POST'])
|
||||
@login_required
|
||||
def accept_terms_of_use():
|
||||
current_user.terms_of_use_accepted = True
|
||||
db.session.commit()
|
||||
|
||||
return jsonify('You accepted the terms of use'), 202
|
||||
|
||||
|
||||
|
||||
@bp.route('/social')
|
||||
@login_required
|
||||
def social():
|
||||
|
@ -132,19 +132,3 @@ def delete_user_avatar(user_id: int):
|
||||
thread.start()
|
||||
|
||||
return jsonify('Avatar marked for deletion'), 202
|
||||
|
||||
|
||||
# TODO: Move this to main blueprint(?)
|
||||
@bp.route('/accept-terms-of-use', methods=['POST'])
|
||||
@login_required
|
||||
def accept_terms_of_use():
|
||||
if not (
|
||||
current_user.is_authenticated
|
||||
or current_user.confirmed
|
||||
):
|
||||
abort(403)
|
||||
|
||||
current_user.terms_of_use_accepted = True
|
||||
db.session.commit()
|
||||
|
||||
return jsonify('You accepted the terms of use'), 202
|
||||
|
Reference in New Issue
Block a user