ongeki: fix frontend versions

This commit is contained in:
Hay1tsme 2024-06-09 03:14:43 -04:00
parent b4b8650acc
commit e69922d91b
5 changed files with 26 additions and 19 deletions

View File

@ -960,7 +960,7 @@ class DLReport:
return True
cfg_dir = environ.get("DIANA_CFG_DIR", "config")
cfg_dir = environ.get("ARTEMIS_CFG_DIR", "config")
cfg: CoreConfig = CoreConfig()
if path.exists(f"{cfg_dir}/core.yaml"):
cfg.update(yaml.safe_load(open(f"{cfg_dir}/core.yaml")))

View File

@ -193,7 +193,7 @@ class FE_Base():
), media_type="text/html; charset=utf-8")
if sesh is None:
resp.delete_cookie("DIANA_SESH")
resp.delete_cookie("ARTEMIS_SESH")
return resp
def get_routes(self) -> List[Route]:
@ -218,6 +218,7 @@ class FE_Base():
sesh.permissions = tk['permissions']
sesh.chunithm_version = tk['chunithm_version']
sesh.maimai_version = tk['maimai_version']
sesh.ongeki_version = tk['ongeki_version']
if sesh.user_id <= 0:
self.logger.error("User session failed to validate due to an invalid ID!")
@ -243,7 +244,7 @@ class FE_Base():
return UserSession()
def validate_session(self, request: Request) -> Optional[UserSession]:
sesh = request.cookies.get('DIANA_SESH', "")
sesh = request.cookies.get('ARTEMIS_SESH', "")
if not sesh:
return None
@ -304,7 +305,7 @@ class FE_Gate(FE_Base):
error=err,
sesh=vars(UserSession()),
), media_type="text/html; charset=utf-8")
resp.delete_cookie("DIANA_SESH")
resp.delete_cookie("ARTEMIS_SESH")
return resp
async def render_login(self, request: Request):
@ -354,7 +355,7 @@ class FE_Gate(FE_Base):
usr_sesh = self.encode_session(sesh)
self.logger.debug(f"Created session with JWT {usr_sesh}")
resp = RedirectResponse("/user/", 303)
resp.set_cookie("DIANA_SESH", usr_sesh)
resp.set_cookie("ARTEMIS_SESH", usr_sesh)
return resp
@ -393,7 +394,7 @@ class FE_Gate(FE_Base):
usr_sesh = self.encode_session(sesh)
self.logger.debug(f"Created session with JWT {usr_sesh}")
resp = RedirectResponse("/user/", 303)
resp.set_cookie("DIANA_SESH", usr_sesh)
resp.set_cookie("ARTEMIS_SESH", usr_sesh)
return resp
@ -511,7 +512,7 @@ class FE_User(FE_Base):
async def render_logout(self, request: Request):
resp = RedirectResponse("/gate/", 303)
resp.delete_cookie("DIANA_SESH")
resp.delete_cookie("ARTEMIS_SESH")
return resp
async def edit_card(self, request: Request) -> RedirectResponse:
@ -895,7 +896,7 @@ class FE_Machine(FE_Base):
arcade={}
), media_type="text/html; charset=utf-8")
cfg_dir = environ.get("DIANA_CFG_DIR", "config")
cfg_dir = environ.get("ARTEMIS_CFG_DIR", "config")
cfg: CoreConfig = CoreConfig()
if path.exists(f"{cfg_dir}/core.yaml"):
cfg.update(yaml.safe_load(open(f"{cfg_dir}/core.yaml")))

View File

@ -68,7 +68,7 @@ class ChuniFrontend(FE_Base):
if usr_sesh.chunithm_version >= 0:
encoded_sesh = self.encode_session(usr_sesh)
resp.set_cookie("DIANA_SESH", encoded_sesh)
resp.set_cookie("ARTEMIS_SESH", encoded_sesh)
return resp
else:
@ -240,7 +240,7 @@ class ChuniFrontend(FE_Base):
encoded_sesh = self.encode_session(usr_sesh)
self.logger.info(f"Created session with JWT {encoded_sesh}")
resp = RedirectResponse("/game/chuni/", 303)
resp.set_cookie("DIANA_SESH", encoded_sesh)
resp.set_cookie("ARTEMIS_SESH", encoded_sesh)
return resp
else:
return RedirectResponse("/gate/", 303)

View File

@ -67,8 +67,8 @@ class Mai2Frontend(FE_Base):
if usr_sesh.maimai_version >= 0:
encoded_sesh = self.encode_session(usr_sesh)
resp.delete_cookie("DIANA_SESH")
resp.set_cookie("DIANA_SESH", encoded_sesh)
resp.delete_cookie("ARTEMIS_SESH")
resp.set_cookie("ARTEMIS_SESH", encoded_sesh)
return resp
else:
@ -184,7 +184,7 @@ class Mai2Frontend(FE_Base):
encoded_sesh = self.encode_session(usr_sesh)
self.logger.info(f"Created session with JWT {encoded_sesh}")
resp = RedirectResponse("/game/mai2/", 303)
resp.set_cookie("DIANA_SESH", encoded_sesh)
resp.set_cookie("ARTEMIS_SESH", encoded_sesh)
return resp
else:
return RedirectResponse("/gate/", 303)

View File

@ -31,7 +31,8 @@ class OngekiFrontend(FE_Base):
def get_routes(self) -> List[Route]:
return [
Route("/", self.render_GET)
Route("/", self.render_GET),
Route("/version.change", self.render_POST, methods=['POST'])
]
async def render_GET(self, request: Request) -> bytes:
@ -69,29 +70,34 @@ class OngekiFrontend(FE_Base):
return RedirectResponse("/gate/", 303)
async def render_POST(self, request: Request):
uri = request.uri.decode()
uri = request.url.path
frm = await request.form()
usr_sesh = self.validate_session(request)
if not usr_sesh:
usr_sesh = UserSession()
if usr_sesh.user_id > 0:
if uri == "/game/ongeki/rival.add":
rival_id = request.args[b"rivalUserId"][0].decode()
rival_id = frm.get("rivalUserId")
await self.data.profile.put_rival(usr_sesh.user_id, rival_id)
# self.logger.info(f"{usr_sesh.user_id} added a rival")
return RedirectResponse(b"/game/ongeki/", 303)
elif uri == "/game/ongeki/rival.delete":
rival_id = request.args[b"rivalUserId"][0].decode()
rival_id = frm.get("rivalUserId")
await self.data.profile.delete_rival(usr_sesh.user_id, rival_id)
# self.logger.info(f"{response}")
return RedirectResponse(b"/game/ongeki/", 303)
elif uri == "/game/ongeki/version.change":
ongeki_version=request.args[b"version"][0].decode()
ongeki_version=frm.get("version")
if(ongeki_version.isdigit()):
usr_sesh.ongeki_version=int(ongeki_version)
return RedirectResponse("/game/ongeki/", 303)
enc = self.encode_session(usr_sesh)
resp = RedirectResponse("/game/ongeki/", 303)
resp.delete_cookie('ARTEMIS_SESH')
resp.set_cookie('ARTEMIS_SESH', enc)
return resp
else:
Response("Something went wrong", status_code=500)