mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-22 22:12:24 +01:00
Add redirect to full user URL
This commit is contained in:
parent
bbb46ce19a
commit
32ac60256c
@ -37,7 +37,7 @@
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
{% if current_user.is_authenticated %}
|
||||
<li><a href="{{ url_for('user_profile_page') }}">{{ current_user.first_name or current_user.username }}</a></li>
|
||||
<li><a href="{{ url_for('user_profile_page', username=current_user.username) }}">{{ current_user.display_name }}</a></li>
|
||||
<li><a href="{{ url_for('user.logout') }}">Sign out</a></li>
|
||||
{% else %}
|
||||
<li><a href="{{ url_for('user.login') }}">Sign in</a></li>
|
||||
|
@ -20,20 +20,18 @@ class UserProfileForm(FlaskForm):
|
||||
display_name = StringField("Display name")
|
||||
submit = SubmitField('Save')
|
||||
|
||||
@app.route('/user/', methods=['GET', 'POST'])
|
||||
@app.route('/user/<username>/', methods=['GET'])
|
||||
def user_profile_page(username=None):
|
||||
user = None
|
||||
form = None
|
||||
if username is None:
|
||||
if not current_user.is_authenticated:
|
||||
return current_app.login_manager.unauthorized()
|
||||
user = current_user
|
||||
else:
|
||||
user = User.query.filter_by(username=username).first()
|
||||
if not user:
|
||||
abort(404)
|
||||
@app.route('/user/', methods=['GET'])
|
||||
@login_required
|
||||
def self_user_profile_page():
|
||||
return redirect(url_for("user_profile_page", username=current_user.username))
|
||||
|
||||
@app.route('/user/<username>/', methods=['GET', 'POST'])
|
||||
def user_profile_page(username):
|
||||
user = User.query.filter_by(username=username).first()
|
||||
if not user:
|
||||
abort(404)
|
||||
|
||||
form = None
|
||||
if user == current_user:
|
||||
# Initialize form
|
||||
form = UserProfileForm(formdata=request.form, obj=current_user)
|
||||
|
Loading…
Reference in New Issue
Block a user