forked from Hay1tsme/artemis
ongeki: fix frontend versions
This commit is contained in:
parent
b4b8650acc
commit
e69922d91b
@ -960,7 +960,7 @@ class DLReport:
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
cfg_dir = environ.get("DIANA_CFG_DIR", "config")
|
cfg_dir = environ.get("ARTEMIS_CFG_DIR", "config")
|
||||||
cfg: CoreConfig = CoreConfig()
|
cfg: CoreConfig = CoreConfig()
|
||||||
if path.exists(f"{cfg_dir}/core.yaml"):
|
if path.exists(f"{cfg_dir}/core.yaml"):
|
||||||
cfg.update(yaml.safe_load(open(f"{cfg_dir}/core.yaml")))
|
cfg.update(yaml.safe_load(open(f"{cfg_dir}/core.yaml")))
|
||||||
|
@ -193,7 +193,7 @@ class FE_Base():
|
|||||||
), media_type="text/html; charset=utf-8")
|
), media_type="text/html; charset=utf-8")
|
||||||
|
|
||||||
if sesh is None:
|
if sesh is None:
|
||||||
resp.delete_cookie("DIANA_SESH")
|
resp.delete_cookie("ARTEMIS_SESH")
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
def get_routes(self) -> List[Route]:
|
def get_routes(self) -> List[Route]:
|
||||||
@ -218,6 +218,7 @@ class FE_Base():
|
|||||||
sesh.permissions = tk['permissions']
|
sesh.permissions = tk['permissions']
|
||||||
sesh.chunithm_version = tk['chunithm_version']
|
sesh.chunithm_version = tk['chunithm_version']
|
||||||
sesh.maimai_version = tk['maimai_version']
|
sesh.maimai_version = tk['maimai_version']
|
||||||
|
sesh.ongeki_version = tk['ongeki_version']
|
||||||
|
|
||||||
if sesh.user_id <= 0:
|
if sesh.user_id <= 0:
|
||||||
self.logger.error("User session failed to validate due to an invalid ID!")
|
self.logger.error("User session failed to validate due to an invalid ID!")
|
||||||
@ -243,7 +244,7 @@ class FE_Base():
|
|||||||
return UserSession()
|
return UserSession()
|
||||||
|
|
||||||
def validate_session(self, request: Request) -> Optional[UserSession]:
|
def validate_session(self, request: Request) -> Optional[UserSession]:
|
||||||
sesh = request.cookies.get('DIANA_SESH', "")
|
sesh = request.cookies.get('ARTEMIS_SESH', "")
|
||||||
if not sesh:
|
if not sesh:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -304,7 +305,7 @@ class FE_Gate(FE_Base):
|
|||||||
error=err,
|
error=err,
|
||||||
sesh=vars(UserSession()),
|
sesh=vars(UserSession()),
|
||||||
), media_type="text/html; charset=utf-8")
|
), media_type="text/html; charset=utf-8")
|
||||||
resp.delete_cookie("DIANA_SESH")
|
resp.delete_cookie("ARTEMIS_SESH")
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
async def render_login(self, request: Request):
|
async def render_login(self, request: Request):
|
||||||
@ -354,7 +355,7 @@ class FE_Gate(FE_Base):
|
|||||||
usr_sesh = self.encode_session(sesh)
|
usr_sesh = self.encode_session(sesh)
|
||||||
self.logger.debug(f"Created session with JWT {usr_sesh}")
|
self.logger.debug(f"Created session with JWT {usr_sesh}")
|
||||||
resp = RedirectResponse("/user/", 303)
|
resp = RedirectResponse("/user/", 303)
|
||||||
resp.set_cookie("DIANA_SESH", usr_sesh)
|
resp.set_cookie("ARTEMIS_SESH", usr_sesh)
|
||||||
|
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
@ -393,7 +394,7 @@ class FE_Gate(FE_Base):
|
|||||||
usr_sesh = self.encode_session(sesh)
|
usr_sesh = self.encode_session(sesh)
|
||||||
self.logger.debug(f"Created session with JWT {usr_sesh}")
|
self.logger.debug(f"Created session with JWT {usr_sesh}")
|
||||||
resp = RedirectResponse("/user/", 303)
|
resp = RedirectResponse("/user/", 303)
|
||||||
resp.set_cookie("DIANA_SESH", usr_sesh)
|
resp.set_cookie("ARTEMIS_SESH", usr_sesh)
|
||||||
|
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
@ -511,7 +512,7 @@ class FE_User(FE_Base):
|
|||||||
|
|
||||||
async def render_logout(self, request: Request):
|
async def render_logout(self, request: Request):
|
||||||
resp = RedirectResponse("/gate/", 303)
|
resp = RedirectResponse("/gate/", 303)
|
||||||
resp.delete_cookie("DIANA_SESH")
|
resp.delete_cookie("ARTEMIS_SESH")
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
async def edit_card(self, request: Request) -> RedirectResponse:
|
async def edit_card(self, request: Request) -> RedirectResponse:
|
||||||
@ -895,7 +896,7 @@ class FE_Machine(FE_Base):
|
|||||||
arcade={}
|
arcade={}
|
||||||
), media_type="text/html; charset=utf-8")
|
), 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()
|
cfg: CoreConfig = CoreConfig()
|
||||||
if path.exists(f"{cfg_dir}/core.yaml"):
|
if path.exists(f"{cfg_dir}/core.yaml"):
|
||||||
cfg.update(yaml.safe_load(open(f"{cfg_dir}/core.yaml")))
|
cfg.update(yaml.safe_load(open(f"{cfg_dir}/core.yaml")))
|
||||||
|
@ -68,7 +68,7 @@ class ChuniFrontend(FE_Base):
|
|||||||
|
|
||||||
if usr_sesh.chunithm_version >= 0:
|
if usr_sesh.chunithm_version >= 0:
|
||||||
encoded_sesh = self.encode_session(usr_sesh)
|
encoded_sesh = self.encode_session(usr_sesh)
|
||||||
resp.set_cookie("DIANA_SESH", encoded_sesh)
|
resp.set_cookie("ARTEMIS_SESH", encoded_sesh)
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@ -240,7 +240,7 @@ class ChuniFrontend(FE_Base):
|
|||||||
encoded_sesh = self.encode_session(usr_sesh)
|
encoded_sesh = self.encode_session(usr_sesh)
|
||||||
self.logger.info(f"Created session with JWT {encoded_sesh}")
|
self.logger.info(f"Created session with JWT {encoded_sesh}")
|
||||||
resp = RedirectResponse("/game/chuni/", 303)
|
resp = RedirectResponse("/game/chuni/", 303)
|
||||||
resp.set_cookie("DIANA_SESH", encoded_sesh)
|
resp.set_cookie("ARTEMIS_SESH", encoded_sesh)
|
||||||
return resp
|
return resp
|
||||||
else:
|
else:
|
||||||
return RedirectResponse("/gate/", 303)
|
return RedirectResponse("/gate/", 303)
|
@ -67,8 +67,8 @@ class Mai2Frontend(FE_Base):
|
|||||||
|
|
||||||
if usr_sesh.maimai_version >= 0:
|
if usr_sesh.maimai_version >= 0:
|
||||||
encoded_sesh = self.encode_session(usr_sesh)
|
encoded_sesh = self.encode_session(usr_sesh)
|
||||||
resp.delete_cookie("DIANA_SESH")
|
resp.delete_cookie("ARTEMIS_SESH")
|
||||||
resp.set_cookie("DIANA_SESH", encoded_sesh)
|
resp.set_cookie("ARTEMIS_SESH", encoded_sesh)
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@ -184,7 +184,7 @@ class Mai2Frontend(FE_Base):
|
|||||||
encoded_sesh = self.encode_session(usr_sesh)
|
encoded_sesh = self.encode_session(usr_sesh)
|
||||||
self.logger.info(f"Created session with JWT {encoded_sesh}")
|
self.logger.info(f"Created session with JWT {encoded_sesh}")
|
||||||
resp = RedirectResponse("/game/mai2/", 303)
|
resp = RedirectResponse("/game/mai2/", 303)
|
||||||
resp.set_cookie("DIANA_SESH", encoded_sesh)
|
resp.set_cookie("ARTEMIS_SESH", encoded_sesh)
|
||||||
return resp
|
return resp
|
||||||
else:
|
else:
|
||||||
return RedirectResponse("/gate/", 303)
|
return RedirectResponse("/gate/", 303)
|
@ -31,7 +31,8 @@ class OngekiFrontend(FE_Base):
|
|||||||
|
|
||||||
def get_routes(self) -> List[Route]:
|
def get_routes(self) -> List[Route]:
|
||||||
return [
|
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:
|
async def render_GET(self, request: Request) -> bytes:
|
||||||
@ -69,29 +70,34 @@ class OngekiFrontend(FE_Base):
|
|||||||
return RedirectResponse("/gate/", 303)
|
return RedirectResponse("/gate/", 303)
|
||||||
|
|
||||||
async def render_POST(self, request: Request):
|
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)
|
usr_sesh = self.validate_session(request)
|
||||||
if not usr_sesh:
|
if not usr_sesh:
|
||||||
usr_sesh = UserSession()
|
usr_sesh = UserSession()
|
||||||
|
|
||||||
if usr_sesh.user_id > 0:
|
if usr_sesh.user_id > 0:
|
||||||
if uri == "/game/ongeki/rival.add":
|
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)
|
await self.data.profile.put_rival(usr_sesh.user_id, rival_id)
|
||||||
# self.logger.info(f"{usr_sesh.user_id} added a rival")
|
# self.logger.info(f"{usr_sesh.user_id} added a rival")
|
||||||
return RedirectResponse(b"/game/ongeki/", 303)
|
return RedirectResponse(b"/game/ongeki/", 303)
|
||||||
|
|
||||||
elif uri == "/game/ongeki/rival.delete":
|
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)
|
await self.data.profile.delete_rival(usr_sesh.user_id, rival_id)
|
||||||
# self.logger.info(f"{response}")
|
# self.logger.info(f"{response}")
|
||||||
return RedirectResponse(b"/game/ongeki/", 303)
|
return RedirectResponse(b"/game/ongeki/", 303)
|
||||||
|
|
||||||
elif uri == "/game/ongeki/version.change":
|
elif uri == "/game/ongeki/version.change":
|
||||||
ongeki_version=request.args[b"version"][0].decode()
|
ongeki_version=frm.get("version")
|
||||||
if(ongeki_version.isdigit()):
|
if(ongeki_version.isdigit()):
|
||||||
usr_sesh.ongeki_version=int(ongeki_version)
|
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:
|
else:
|
||||||
Response("Something went wrong", status_code=500)
|
Response("Something went wrong", status_code=500)
|
||||||
|
Loading…
Reference in New Issue
Block a user