Add play uri param

Signed-off-by: Gregoire Parant <g.parant@thecodingmachine.com>
This commit is contained in:
Gregoire Parant 2022-02-08 18:47:11 +01:00
parent 876ddc87d2
commit 64ba7575a0
3 changed files with 17 additions and 7 deletions

View File

@ -130,9 +130,12 @@ class ConnectionManager {
//clear queryPrivateAccessToken query in window location //clear queryPrivateAccessToken query in window location
urlParams.delete(queryPrivateAccessToken); urlParams.delete(queryPrivateAccessToken);
const data = await Axios.post(`${PUSHER_URL}/register`, { organizationMemberToken }).then( //create play uri parameter
(res) => res.data 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)) { if (!isRegisterData(data)) {
console.error("Invalid data received from /register route. Data: ", data); console.error("Invalid data received from /register route. Data: ", data);
throw new Error("Invalid data received from /register route."); throw new Error("Invalid data received from /register route.");

View File

@ -170,10 +170,11 @@ export class AuthenticateController extends BaseController {
//todo: what to do if the organizationMemberToken is already used? //todo: what to do if the organizationMemberToken is already used?
const organizationMemberToken: string | null = param.organizationMemberToken; const organizationMemberToken: string | null = param.organizationMemberToken;
const playUri: string | null = param.playUri;
try { try {
if (typeof organizationMemberToken != "string") throw new Error("No organization token"); 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 userUuid = data.userUuid;
const email = data.email; const email = data.email;
const roomUrl = data.roomUrl; const roomUrl = data.roomUrl;

View File

@ -47,25 +47,31 @@ class AdminApi {
async fetchMemberDataByUuid( async fetchMemberDataByUuid(
userIdentifier: string | null, userIdentifier: string | null,
roomId: string, playUri: string,
ipAddress: string ipAddress: string
): Promise<FetchMemberDataByUuidResponse> { ): Promise<FetchMemberDataByUuidResponse> {
if (!ADMIN_API_URL) { if (!ADMIN_API_URL) {
return Promise.reject(new Error("No admin backoffice set!")); return Promise.reject(new Error("No admin backoffice set!"));
} }
const res = await Axios.get(ADMIN_API_URL + "/api/room/access", { 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}` }, headers: { Authorization: `${ADMIN_API_TOKEN}` },
}); });
return res.data; return res.data;
} }
async fetchMemberDataByToken(organizationMemberToken: string): Promise<AdminApiData> { async fetchMemberDataByToken(organizationMemberToken: string, playUri: string | null): Promise<AdminApiData> {
if (!ADMIN_API_URL) { if (!ADMIN_API_URL) {
return Promise.reject(new Error("No admin backoffice set!")); 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. //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, { const res = await Axios.get(ADMIN_API_URL + "/api/login-url/" + organizationMemberToken, {
params: { playUri },
headers: { Authorization: `${ADMIN_API_TOKEN}` }, headers: { Authorization: `${ADMIN_API_TOKEN}` },
}); });
if (!isAdminApiData(res.data)) { if (!isAdminApiData(res.data)) {