Use a better redirect mechanic in the proxied settings route

This commit is contained in:
Patrick Jentsch 2023-04-04 08:44:25 +02:00
parent 87798f4781
commit a27caaa8a2
4 changed files with 13 additions and 8 deletions

View File

@ -8,7 +8,4 @@ from . import bp
@bp.route('/settings', methods=['GET', 'POST'])
@register_breadcrumb(bp, '.', '<i class="material-icons left">settings</i>Settings')
def settings():
return settings_route(
current_user.id,
redirect_location_on_post=url_for('.settings')
)
return settings_route(current_user.id)

View File

@ -1,6 +1,8 @@
{% extends "settings/settings.html.j2" %}
{% block admin_settings %}
<div class="col s12"></div>
<div class="col s12 l4">
<h4>Administrator Settings</h4>
<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam

View File

@ -102,6 +102,8 @@
</ul>
</div>
<div class="col s12"></div>
<div class="col s12 l4">
<h4>General Settings</h4>
<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam

View File

@ -1,4 +1,4 @@
from flask import abort, flash, redirect, render_template, url_for
from flask import abort, flash, g, redirect, render_template, url_for
from flask_breadcrumbs import register_breadcrumb
from flask_login import current_user, login_required
from app import db
@ -17,12 +17,16 @@ from .forms import (
@bp.route('/<hashid:user_id>/settings', methods=['GET', 'POST'])
@register_breadcrumb(bp, '.entity.settings', '<i class="material-icons left">settings</i>Settings', endpoint_arguments_constructor=user_eac)
@login_required
def settings(user_id, redirect_location_on_post=None):
def settings(user_id):
user = User.query.get_or_404(user_id)
if not (user == current_user or current_user.is_administrator()):
abort(403)
if redirect_location_on_post is None:
redirect_location_on_post = url_for('.settings', user_id=user_id)
redirect_location_on_post = g.pop(
'redirect_location_on_post',
url_for('.settings', user_id=user_id)
)
update_account_information_form = UpdateAccountInformationForm(user)
update_profile_information_form = UpdateProfileInformationForm(user)
update_avatar_form = UpdateAvatarForm()