mirror of
https://github.com/Fluffy-Bean/GameExpo23.git
synced 2025-05-19 09:44:52 +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")
|
||||
|
||||
|
||||
@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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 %}
|
||||
|
|
|
@ -1,47 +1,47 @@
|
|||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
<div class="block">
|
||||
<h2>Hello, {{ current_user.username }}!</h2>
|
||||
<p>Sample text</p>
|
||||
</div>
|
||||
|
||||
<div class="block">
|
||||
<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>
|
||||
<div class="table">
|
||||
<table>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>Device</th>
|
||||
<th>Created</th>
|
||||
<th>Last Used</th>
|
||||
</tr>
|
||||
{% if sessions %}
|
||||
{% for session in sessions %}
|
||||
<tr id="sess-{{ session.id }}">
|
||||
<td><button onclick="yeetSession({{ session.id }})" class="button secondary"><i class="ph ph-trash"></i></button></td>
|
||||
<td>{{ session.device_type }}</td>
|
||||
<td>{{ session.created_at.strftime('%Y-%m-%d') }}</td>
|
||||
<td>{{ session.last_used.strftime('%Y-%m-%d') }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<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>
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
<div class="block">
|
||||
<h2>Hello, {{ current_user.username }}!</h2>
|
||||
<p>Sample text</p>
|
||||
</div>
|
||||
|
||||
<div class="block">
|
||||
<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>
|
||||
<div class="table">
|
||||
<table>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>Device</th>
|
||||
<th>Created</th>
|
||||
<th>Last Used</th>
|
||||
</tr>
|
||||
{% if sessions %}
|
||||
{% for session in sessions %}
|
||||
<tr id="sess-{{ session.id }}">
|
||||
<td><button onclick="yeetSession({{ session.id }})" class="button secondary"><i class="ph ph-trash"></i></button></td>
|
||||
<td>{{ session.device_type }}</td>
|
||||
<td>{{ session.created_at.strftime('%Y-%m-%d') }}</td>
|
||||
<td>{{ session.last_used.strftime('%Y-%m-%d') }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="block secondary">
|
||||
<h2>Danger Zone</h2>
|
||||
<p>Be careful!</p>
|
||||
<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 %}
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue