From 64ba7575a09d874b6d53edc523b1a8c99c6c0c79 Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Tue, 8 Feb 2022 18:47:11 +0100 Subject: [PATCH] Add play uri param Signed-off-by: Gregoire Parant --- front/src/Connexion/ConnectionManager.ts | 9 ++++++--- pusher/src/Controller/AuthenticateController.ts | 3 ++- pusher/src/Services/AdminApi.ts | 12 +++++++++--- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/front/src/Connexion/ConnectionManager.ts b/front/src/Connexion/ConnectionManager.ts index 6f1984ae..344f9152 100644 --- a/front/src/Connexion/ConnectionManager.ts +++ b/front/src/Connexion/ConnectionManager.ts @@ -130,9 +130,12 @@ class ConnectionManager { //clear queryPrivateAccessToken query in window location urlParams.delete(queryPrivateAccessToken); - const data = await Axios.post(`${PUSHER_URL}/register`, { organizationMemberToken }).then( - (res) => res.data - ); + //create play uri parameter + const playUri = window.location.protocol + "//" + window.location.host; + const data = await Axios.post(`${PUSHER_URL}/register`, { + organizationMemberToken, + playUri, + }).then((res) => res.data); if (!isRegisterData(data)) { console.error("Invalid data received from /register route. Data: ", data); throw new Error("Invalid data received from /register route."); diff --git a/pusher/src/Controller/AuthenticateController.ts b/pusher/src/Controller/AuthenticateController.ts index fe80eafa..046de8fe 100644 --- a/pusher/src/Controller/AuthenticateController.ts +++ b/pusher/src/Controller/AuthenticateController.ts @@ -170,10 +170,11 @@ export class AuthenticateController extends BaseController { //todo: what to do if the organizationMemberToken is already used? const organizationMemberToken: string | null = param.organizationMemberToken; + const playUri: string | null = param.playUri; try { if (typeof organizationMemberToken != "string") throw new Error("No organization token"); - const data = await adminApi.fetchMemberDataByToken(organizationMemberToken); + const data = await adminApi.fetchMemberDataByToken(organizationMemberToken, playUri); const userUuid = data.userUuid; const email = data.email; const roomUrl = data.roomUrl; diff --git a/pusher/src/Services/AdminApi.ts b/pusher/src/Services/AdminApi.ts index c72a6ba8..6fe1d258 100644 --- a/pusher/src/Services/AdminApi.ts +++ b/pusher/src/Services/AdminApi.ts @@ -47,25 +47,31 @@ class AdminApi { async fetchMemberDataByUuid( userIdentifier: string | null, - roomId: string, + playUri: string, ipAddress: string ): Promise { if (!ADMIN_API_URL) { return Promise.reject(new Error("No admin backoffice set!")); } const res = await Axios.get(ADMIN_API_URL + "/api/room/access", { - params: { userIdentifier, roomId, ipAddress }, + params: { + userIdentifier, + roomId: playUri /* @deprecated */, + playUri, + ipAddress, + }, headers: { Authorization: `${ADMIN_API_TOKEN}` }, }); return res.data; } - async fetchMemberDataByToken(organizationMemberToken: string): Promise { + async fetchMemberDataByToken(organizationMemberToken: string, playUri: string | null): Promise { if (!ADMIN_API_URL) { return Promise.reject(new Error("No admin backoffice set!")); } //todo: this call can fail if the corresponding world is not activated or if the token is invalid. Handle that case. const res = await Axios.get(ADMIN_API_URL + "/api/login-url/" + organizationMemberToken, { + params: { playUri }, headers: { Authorization: `${ADMIN_API_TOKEN}` }, }); if (!isAdminApiData(res.data)) {