diff --git a/TFR/server/auth.py b/TFR/server/auth.py index befe6ab..f28d6a8 100644 --- a/TFR/server/auth.py +++ b/TFR/server/auth.py @@ -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 diff --git a/TFR/server/static/sass/style.sass b/TFR/server/static/sass/style.sass index d6fdf73..f80bb22 100644 --- a/TFR/server/static/sass/style.sass +++ b/TFR/server/static/sass/style.sass @@ -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 diff --git a/TFR/server/templates/base.html b/TFR/server/templates/base.html index b29b07b..51bcdc2 100644 --- a/TFR/server/templates/base.html +++ b/TFR/server/templates/base.html @@ -50,7 +50,7 @@ {% if current_user.is_authenticated %} - {{ current_user.username }} + {{ current_user.username }} {% else %} {% endif %} diff --git a/TFR/server/templates/account.html b/TFR/server/templates/settings.html similarity index 78% rename from TFR/server/templates/account.html rename to TFR/server/templates/settings.html index a77482f..6d6e72e 100644 --- a/TFR/server/templates/account.html +++ b/TFR/server/templates/settings.html @@ -1,47 +1,47 @@ -{% extends "base.html" %} -{% block content %} -
-

Hello, {{ current_user.username }}!

-

Sample text

-
- -
-

Sessions

-

Devices and games that you logged into. If you're looking to logout all website users, reset your password instead.

-
- - - - - - - - {% if sessions %} - {% for session in sessions %} - - - - - - - {% endfor %} - {% else %} - - - - - - - {% endif %} -
DeviceCreatedLast Used
{{ session.device_type }}{{ session.created_at.strftime('%Y-%m-%d') }}{{ session.last_used.strftime('%Y-%m-%d') }}
-
-
- -
-

Danger Zone

-

Be careful!

- Delete Account - Reset Password - Logout -
-{% endblock %} +{% extends "base.html" %} +{% block content %} +
+

Hello, {{ current_user.username }}!

+

Sample text

+
+ +
+

Sessions

+

Devices and games that you logged into. If you're looking to logout all website users, reset your password instead.

+
+ + + + + + + + {% if sessions %} + {% for session in sessions %} + + + + + + + {% endfor %} + {% else %} + + + + + + + {% endif %} +
DeviceCreatedLast Used
{{ session.device_type }}{{ session.created_at.strftime('%Y-%m-%d') }}{{ session.last_used.strftime('%Y-%m-%d') }}
+
+
+ +
+

Danger Zone

+

Be careful!

+ Delete Account + Reset Password + Logout +
+{% endblock %} diff --git a/TFR/server/views.py b/TFR/server/views.py index ce29a0d..e7ded8a 100644 --- a/TFR/server/views.py +++ b/TFR/server/views.py @@ -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)