Switch account for settings

This commit is contained in:
Michał Gdula 2023-06-13 02:02:35 +03:00
parent 22b5fa13fb
commit 3d9b387ea8
5 changed files with 69 additions and 68 deletions

View file

@ -18,24 +18,6 @@ def auth():
return render_template("auth.html")
@blueprint.route("/account", methods=["GET"])
@login_required
def account():
action = request.args.get("action", None)
if action == "logout":
logout_user()
flash("Successfully logged out!", "success")
return redirect(url_for("views.index"))
if action == "delete":
flash("Insert delete function", "error")
if action == "password":
flash("Insert password change function", "error")
sessions = Sessions.query.filter_by(user_id=current_user.id).all()
return render_template("account.html", sessions=sessions)
@blueprint.route("/register", methods=["POST"])
def register():
# Get the form data

View file

@ -93,7 +93,7 @@ body
color: RGB($secondary)
text-shadow: 0 0 5px RGBA($secondary, 0.7)
i
> i
padding: 0.25rem
color: RGB($black)
border-radius: 2px

View file

@ -50,7 +50,7 @@
<span class="spacer"></span>
{% if current_user.is_authenticated %}
<a href="{{ url_for('auth.account') }}" class="button primary">{{ current_user.username }}</a>
<a href="{{ url_for('views.settings') }}" class="button primary">{{ current_user.username }}</a>
{% else %}
<a href="{{ url_for('auth.auth') }}" class="button primary"><i class="ph ph-user-circle"></i></a>
{% endif %}

View file

@ -40,8 +40,8 @@
<div class="block secondary">
<h2>Danger Zone</h2>
<p>Be careful!</p>
<a href="{{ url_for('auth.account', action='delete') }}" class="button secondary" style="margin-bottom: 0.5rem">Delete Account</a>
<a href="{{ url_for('auth.account', action='password') }}" class="button secondary" style="margin-bottom: 0.5rem">Reset Password</a>
<a href="{{ url_for('auth.account', action='logout') }}" class="button secondary">Logout</a>
<a href="{{ url_for('views.settings', action='delete') }}" class="button secondary" style="margin-bottom: 0.5rem">Delete Account</a>
<a href="{{ url_for('views.settings', action='password') }}" class="button secondary" style="margin-bottom: 0.5rem">Reset Password</a>
<a href="{{ url_for('views.settings', action='logout') }}" class="button secondary">Logout</a>
</div>
{% endblock %}

View file

@ -1,5 +1,6 @@
from flask import Blueprint, request, render_template, abort
from server.models import Scores, Users
from flask_login import login_required, current_user, logout_user
from server.models import Scores, Users, Sessions
from server.config import GAME_VERSION, MAX_TOP_SCORES
@ -33,3 +34,21 @@ def index():
@blueprint.route("/about")
def about():
return render_template("about.html")
@blueprint.route("/settings", methods=["GET"])
@login_required
def settings():
action = request.args.get("action", None)
if action == "logout":
logout_user()
flash("Successfully logged out!", "success")
return redirect(url_for("views.index"))
if action == "delete":
flash("Insert delete function", "error")
if action == "password":
flash("Insert password change function", "error")
sessions = Sessions.query.filter_by(user_id=current_user.id).all()
return render_template("settings.html", sessions=sessions)