frontend: user page fixes, add card display

This commit is contained in:
Hay1tsme 2023-05-20 15:32:02 -04:00
parent 97892d6a7d
commit 4da8622977
6 changed files with 61 additions and 7 deletions

View File

@ -80,6 +80,9 @@ class UserData(BaseData):
if usr["password"] is None:
return False
if passwd is None or not passwd:
return False
return bcrypt.checkpw(passwd, usr["password"].encode())
def reset_autoincrement(self, ai_value: int) -> None:

View File

@ -182,7 +182,7 @@ class FE_Gate(FE_Base):
access_code: str = request.args[b"access_code"][0].decode()
username: str = request.args[b"username"][0]
email: str = request.args[b"email"][0].decode()
passwd: str = request.args[b"passwd"][0]
passwd: bytes = request.args[b"passwd"][0]
uid = self.data.card.get_user_id_from_card(access_code)
if uid is None:
@ -197,7 +197,7 @@ class FE_Gate(FE_Base):
if result is None:
return redirectTo(b"/gate?e=3", request)
if not self.data.user.check_password(uid, passwd.encode()):
if not self.data.user.check_password(uid, passwd):
return redirectTo(b"/gate", request)
return redirectTo(b"/user", request)
@ -228,8 +228,21 @@ class FE_User(FE_Base):
if usr_sesh.userId == 0:
return redirectTo(b"/gate", request)
cards = self.data.card.get_user_cards(usr_sesh.userId)
user = self.data.user.get_user(usr_sesh.userId)
card_data = []
for c in cards:
if c['is_locked']:
status = 'Locked'
elif c['is_banned']:
status = 'Banned'
else:
status = 'Active'
card_data.append({'access_code': c['access_code'], 'status': status})
return template.render(
title=f"{self.core_config.server.name} | Account", sesh=vars(usr_sesh)
title=f"{self.core_config.server.name} | Account", sesh=vars(usr_sesh), cards=card_data, username=user['username']
).encode("utf-16")

View File

@ -1,4 +1,31 @@
{% extends "core/frontend/index.jinja" %}
{% block content %}
<h1>testing</h1>
<h1>Management for {{ username }}</h1>
<h2>Cards <button class="btn btn-success" data-bs-toggle="modal" data-bs-target="#card_add">Add</button></h2>
<ul>
{% for c in cards %}
<li>{{ c.access_code }}: {{ c.status }} <button class="btn-danger btn">Delete</button></li>
{% endfor %}
</ul>
<div class="modal fade" id="card_add" tabindex="-1" aria-labelledby="card_add_label" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="card_add_label">Add Card</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
HOW TO:<br>
Scan your card on any networked game and press the "View Access Code" button (varies by game) and enter the 20 digit code below.<br>
!!FOR AMUSEIC CARDS: DO NOT ENTER THE CODE SHOWN ON THE BACK OF THE CARD ITSELF OR IT WILL NOT WORK!!
<p /><label for="card_add_frm_access_code">Access Code:&nbsp;</label><input id="card_add_frm_access_code" maxlength="20" type="text" required>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary">Add</button>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
{% endblock content %}

View File

@ -4,7 +4,7 @@
<div style="background: #333; color: #f9f9f9; width: 80%; height: 50px; line-height: 50px; padding-left: 10px; float: left;">
<a href=/><button class="btn btn-primary">Home</button></a>&nbsp;
{% for game in game_list %}
<a href=game/{{ game.url }}><button class="btn btn-success">{{ game.name }}</button></a>&nbsp;
<a href=/game/{{ game.url }}><button class="btn btn-success">{{ game.name }}</button></a>&nbsp;
{% endfor %}
</div>
</div>

View File

@ -2,8 +2,9 @@ import yaml
import jinja2
from twisted.web.http import Request
from os import path
from twisted.web.server import Session
from core.frontend import FE_Base
from core.frontend import FE_Base, IUserSession
from core.config import CoreConfig
from .database import PokkenData
from .config import PokkenConfig
@ -27,7 +28,12 @@ class PokkenFrontend(FE_Base):
template = self.environment.get_template(
"titles/pokken/frontend/pokken_index.jinja"
)
sesh: Session = request.getSession()
usr_sesh = IUserSession(sesh)
return template.render(
title=f"{self.core_config.server.name} | {self.nav_name}",
game_list=self.environment.globals["game_list"],
sesh=vars(usr_sesh)
).encode("utf-16")

View File

@ -2,8 +2,9 @@ import yaml
import jinja2
from twisted.web.http import Request
from os import path
from twisted.web.server import Session
from core.frontend import FE_Base
from core.frontend import FE_Base, IUserSession
from core.config import CoreConfig
from titles.wacca.database import WaccaData
from titles.wacca.config import WaccaConfig
@ -27,7 +28,11 @@ class WaccaFrontend(FE_Base):
template = self.environment.get_template(
"titles/wacca/frontend/wacca_index.jinja"
)
sesh: Session = request.getSession()
usr_sesh = IUserSession(sesh)
return template.render(
title=f"{self.core_config.server.name} | {self.nav_name}",
game_list=self.environment.globals["game_list"],
sesh=vars(usr_sesh)
).encode("utf-16")