diff --git a/front/src/Connexion/ConnectionManager.ts b/front/src/Connexion/ConnectionManager.ts index c0aed225..81e2492e 100644 --- a/front/src/Connexion/ConnectionManager.ts +++ b/front/src/Connexion/ConnectionManager.ts @@ -345,20 +345,6 @@ class ConnectionManager { gameManager.setPlayerName(username); } - const layers: string[] = []; - if (textures) { - let i = 0; - for (const layerItem of textures) { - if (layerItem !== undefined) { - layers.push(layerItem.id); - } - i++; - } - if (layers.length > 0) { - gameManager.setCharacterLayers(layers); - } - } - if (locale) { try { if (locales.indexOf(locale) == -1) { @@ -376,6 +362,18 @@ class ConnectionManager { } } + if (textures) { + const layers: string[] = []; + for (const texture of textures) { + if (texture !== undefined) { + layers.push(texture.id); + } + } + if (layers.length > 0) { + gameManager.setCharacterLayers(layers); + } + } + //user connected, set connected store for menu at true userIsConnected.set(true); } diff --git a/front/src/Phaser/Login/CustomizeScene.ts b/front/src/Phaser/Login/CustomizeScene.ts index 918cf9cf..30fbd77d 100644 --- a/front/src/Phaser/Login/CustomizeScene.ts +++ b/front/src/Phaser/Login/CustomizeScene.ts @@ -46,7 +46,7 @@ export class CustomizeScene extends AbstractCharacterScene { // FIXME: window.location.href is wrong. We need the URL of the main room (so we need to apply any redirect before!) this.load.json( wokaMetadataKey, - `${PUSHER_URL}/woka/list/` + encodeURIComponent(window.location.href), + `${PUSHER_URL}/woka/list?roomUrl=` + encodeURIComponent(window.location.href), undefined, { responseType: "text", diff --git a/front/src/Phaser/Login/SelectCharacterScene.ts b/front/src/Phaser/Login/SelectCharacterScene.ts index f7fd3c8a..064739f5 100644 --- a/front/src/Phaser/Login/SelectCharacterScene.ts +++ b/front/src/Phaser/Login/SelectCharacterScene.ts @@ -50,7 +50,7 @@ export class SelectCharacterScene extends AbstractCharacterScene { // FIXME: window.location.href is wrong. We need the URL of the main room (so we need to apply any redirect before!) this.load.json( wokaMetadataKey, - `${PUSHER_URL}/woka/list/` + encodeURIComponent(window.location.href), + `${PUSHER_URL}/woka/list?roomUrl=` + encodeURIComponent(window.location.href), undefined, { responseType: "text", diff --git a/pusher/src/Controller/WokaListController.ts b/pusher/src/Controller/WokaListController.ts index 56300e90..069297d4 100644 --- a/pusher/src/Controller/WokaListController.ts +++ b/pusher/src/Controller/WokaListController.ts @@ -1,17 +1,17 @@ import { BaseHttpController } from "./BaseHttpController"; +import { parse } from "query-string"; import { wokaService } from "../Services/WokaService"; -import * as tg from "generic-type-guard"; import { jwtTokenManager } from "../Services/JWTTokenManager"; export class WokaListController extends BaseHttpController { routes() { - this.app.options("/woka/list/:roomUrl", {}, (req, res) => { + this.app.options("/woka/list", {}, (req, res) => { res.status(200).send(""); return; }); // eslint-disable-next-line @typescript-eslint/no-misused-promises - this.app.get("/woka/list/:roomUrl", {}, async (req, res) => { + this.app.get("/woka/list", {}, async (req, res) => { const token = req.header("Authorization"); if (!token) { @@ -29,17 +29,13 @@ export class WokaListController extends BaseHttpController { return; } - const isParameters = new tg.IsInterface() - .withProperties({ - roomUrl: tg.isString, - }) - .get(); + let { roomUrl } = parse(req.path_query); - if (!isParameters(req.path_parameters)) { - return res.status(400).send("Unknown parameters"); + if (typeof roomUrl !== "string") { + throw new Error("missing roomUrl URL parameter"); } - const roomUrl = decodeURIComponent(req.path_parameters.roomUrl); + roomUrl = decodeURIComponent(roomUrl); const wokaList = await wokaService.getWokaList(roomUrl, req.params["uuid"]); if (!wokaList) {