From 5507a91d48c9744c65aa462f2e2344e86604d2a7 Mon Sep 17 00:00:00 2001 From: CEC Date: Wed, 13 Apr 2022 18:40:14 +0200 Subject: [PATCH 1/4] Add fetchMapDetails for the mocking LocalAPI --- pusher/src/Services/LocalAdmin.ts | 37 +++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/pusher/src/Services/LocalAdmin.ts b/pusher/src/Services/LocalAdmin.ts index 4e2c41a0..74edb1c3 100644 --- a/pusher/src/Services/LocalAdmin.ts +++ b/pusher/src/Services/LocalAdmin.ts @@ -1,5 +1,9 @@ -import { FetchMemberDataByUuidResponse } from "./AdminApi"; -import { AdminInterface } from "./AdminInterface"; +import {FetchMemberDataByUuidResponse} from "./AdminApi"; +import {AdminInterface} from "./AdminInterface"; +import {MapDetailsData} from "../Messages/JsonMessages/MapDetailsData"; +import {RoomRedirect} from "../Messages/JsonMessages/RoomRedirect"; +import {GameRoomPolicyTypes} from "../Model/PusherRoom"; +import {DISABLE_ANONYMOUS} from "../Enum/EnvironmentVariable"; /** * A local class mocking a real admin if no admin is configured. @@ -24,6 +28,35 @@ class LocalAdmin implements AdminInterface { userRoomToken: undefined, }); } + + fetchMapDetails( + playUri: string, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + userId?: string + ): Promise { + + const roomUrl = new URL(playUri); + + const match = /\/_\/[^/]+\/(.+)/.exec(roomUrl.pathname); + if (!match) { + throw new Error("URL format is not good"); + } + + const mapUrl = roomUrl.protocol + "//" + match[1]; + + return Promise.resolve({ + mapUrl, + policy_type: GameRoomPolicyTypes.ANONYMOUS_POLICY, + tags: [], + authenticationMandatory: DISABLE_ANONYMOUS, + roomSlug: null, + contactPage: null, + group: null, + iframeAuthentication: null, + loadingLogo: null, + loginSceneLogo: null + }); + } } export const localAdmin = new LocalAdmin(); From a13c7e9e2f171ae1dd71ff90cd3e5543b5611a08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?gr=C3=A9goire=20parant?= Date: Thu, 14 Apr 2022 10:17:59 +0200 Subject: [PATCH 2/4] Improve profile menu to implement user identity connected URL (#2055) # Improve profile menu to implement user identity connected URL - Create URL and get user identity - Check if user is connected or show connexion button - Improve profile to check before user data and don't display error webpage in menu --- front/src/Administration/AnalyticsClient.ts | 2 +- .../src/Components/Menu/ProfileSubMenu.svelte | 15 ++-- front/src/Connexion/ConnectionManager.ts | 4 +- front/src/Enum/EnvironmentVariable.ts | 1 + front/src/Stores/MenuStore.ts | 26 +++++- front/vite.config.ts | 1 + .../src/Controller/AuthenticateController.ts | 85 ++++++++++++++++++- 7 files changed, 116 insertions(+), 18 deletions(-) diff --git a/front/src/Administration/AnalyticsClient.ts b/front/src/Administration/AnalyticsClient.ts index 4c1ca93a..8c14eaed 100644 --- a/front/src/Administration/AnalyticsClient.ts +++ b/front/src/Administration/AnalyticsClient.ts @@ -9,7 +9,7 @@ class AnalyticsClient { constructor() { if (POSTHOG_API_KEY && POSTHOG_URL) { this.posthogPromise = import("posthog-js").then(({ default: posthog }) => { - posthog.init(POSTHOG_API_KEY, { api_host: POSTHOG_URL, disable_cookie: true }); + posthog.init(POSTHOG_API_KEY, { api_host: POSTHOG_URL }); //the posthog toolbar need a reference in window to be able to work window.posthog = posthog; return posthog; diff --git a/front/src/Components/Menu/ProfileSubMenu.svelte b/front/src/Components/Menu/ProfileSubMenu.svelte index 09237e36..1c6a744e 100644 --- a/front/src/Components/Menu/ProfileSubMenu.svelte +++ b/front/src/Components/Menu/ProfileSubMenu.svelte @@ -1,7 +1,13 @@