mirror of
https://github.com/Fluffy-Bean/GameExpo23.git
synced 2025-05-19 01:44:51 +00:00
Switch account for settings
This commit is contained in:
parent
22b5fa13fb
commit
3d9b387ea8
5 changed files with 69 additions and 68 deletions
|
@ -18,24 +18,6 @@ def auth():
|
||||||
return render_template("auth.html")
|
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"])
|
@blueprint.route("/register", methods=["POST"])
|
||||||
def register():
|
def register():
|
||||||
# Get the form data
|
# Get the form data
|
||||||
|
|
|
@ -93,7 +93,7 @@ body
|
||||||
color: RGB($secondary)
|
color: RGB($secondary)
|
||||||
text-shadow: 0 0 5px RGBA($secondary, 0.7)
|
text-shadow: 0 0 5px RGBA($secondary, 0.7)
|
||||||
|
|
||||||
i
|
> i
|
||||||
padding: 0.25rem
|
padding: 0.25rem
|
||||||
color: RGB($black)
|
color: RGB($black)
|
||||||
border-radius: 2px
|
border-radius: 2px
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
<span class="spacer"></span>
|
<span class="spacer"></span>
|
||||||
|
|
||||||
{% if current_user.is_authenticated %}
|
{% 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 %}
|
{% else %}
|
||||||
<a href="{{ url_for('auth.auth') }}" class="button primary"><i class="ph ph-user-circle"></i></a>
|
<a href="{{ url_for('auth.auth') }}" class="button primary"><i class="ph ph-user-circle"></i></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -1,47 +1,47 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="block">
|
<div class="block">
|
||||||
<h2>Hello, {{ current_user.username }}!</h2>
|
<h2>Hello, {{ current_user.username }}!</h2>
|
||||||
<p>Sample text</p>
|
<p>Sample text</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="block">
|
<div class="block">
|
||||||
<h2>Sessions</h2>
|
<h2>Sessions</h2>
|
||||||
<p>Devices and games that you logged into. If you're looking to logout all website users, reset your password instead.</p>
|
<p>Devices and games that you logged into. If you're looking to logout all website users, reset your password instead.</p>
|
||||||
<div class="table">
|
<div class="table">
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th></th>
|
<th></th>
|
||||||
<th>Device</th>
|
<th>Device</th>
|
||||||
<th>Created</th>
|
<th>Created</th>
|
||||||
<th>Last Used</th>
|
<th>Last Used</th>
|
||||||
</tr>
|
</tr>
|
||||||
{% if sessions %}
|
{% if sessions %}
|
||||||
{% for session in sessions %}
|
{% for session in sessions %}
|
||||||
<tr id="sess-{{ session.id }}">
|
<tr id="sess-{{ session.id }}">
|
||||||
<td><button onclick="yeetSession({{ session.id }})" class="button secondary"><i class="ph ph-trash"></i></button></td>
|
<td><button onclick="yeetSession({{ session.id }})" class="button secondary"><i class="ph ph-trash"></i></button></td>
|
||||||
<td>{{ session.device_type }}</td>
|
<td>{{ session.device_type }}</td>
|
||||||
<td>{{ session.created_at.strftime('%Y-%m-%d') }}</td>
|
<td>{{ session.created_at.strftime('%Y-%m-%d') }}</td>
|
||||||
<td>{{ session.last_used.strftime('%Y-%m-%d') }}</td>
|
<td>{{ session.last_used.strftime('%Y-%m-%d') }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="block secondary">
|
<div class="block secondary">
|
||||||
<h2>Danger Zone</h2>
|
<h2>Danger Zone</h2>
|
||||||
<p>Be careful!</p>
|
<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('views.settings', 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('views.settings', 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='logout') }}" class="button secondary">Logout</a>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -1,5 +1,6 @@
|
||||||
from flask import Blueprint, request, render_template, abort
|
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
|
from server.config import GAME_VERSION, MAX_TOP_SCORES
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,3 +34,21 @@ def index():
|
||||||
@blueprint.route("/about")
|
@blueprint.route("/about")
|
||||||
def about():
|
def about():
|
||||||
return render_template("about.html")
|
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)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue