diff --git a/core/data/schema/user.py b/core/data/schema/user.py index 98663d1..6a95005 100644 --- a/core/data/schema/user.py +++ b/core/data/schema/user.py @@ -79,6 +79,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()) diff --git a/core/frontend.py b/core/frontend.py index c992e76..9eb30e6 100644 --- a/core/frontend.py +++ b/core/frontend.py @@ -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) @@ -227,9 +227,22 @@ class FE_User(FE_Base): usr_sesh = IUserSession(sesh) 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") diff --git a/core/frontend/user/index.jinja b/core/frontend/user/index.jinja index eabdd18..2911e67 100644 --- a/core/frontend/user/index.jinja +++ b/core/frontend/user/index.jinja @@ -1,4 +1,31 @@ {% extends "core/frontend/index.jinja" %} {% block content %} -

testing

+

Management for {{ username }}

+

Cards

+ + + {% endblock content %} \ No newline at end of file diff --git a/core/frontend/widgets/topbar.jinja b/core/frontend/widgets/topbar.jinja index d196361..fb63ebe 100644 --- a/core/frontend/widgets/topbar.jinja +++ b/core/frontend/widgets/topbar.jinja @@ -4,7 +4,7 @@
  {% for game in game_list %} -   +   {% endfor %}
diff --git a/titles/pokken/frontend.py b/titles/pokken/frontend.py index e4e8947..af344dc 100644 --- a/titles/pokken/frontend.py +++ b/titles/pokken/frontend.py @@ -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") diff --git a/titles/wacca/frontend.py b/titles/wacca/frontend.py index 69ab1ee..cc40644 100644 --- a/titles/wacca/frontend.py +++ b/titles/wacca/frontend.py @@ -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")