From e37ed130f5fd1e6442130938b162dda7fb58d123 Mon Sep 17 00:00:00 2001 From: James Lyne Date: Fri, 17 Jun 2022 13:44:42 +0100 Subject: [PATCH] Add option for custom login URL. Fixes #381. --- index.html | 4 ++++ src/index.d.ts | 1 + src/store/actions.ts | 6 +++++- src/store/mutations.ts | 4 ++++ src/store/state.ts | 2 ++ 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 8267af3..655e163 100644 --- a/index.html +++ b/index.html @@ -180,6 +180,10 @@ // Disable the markers button and list disableMarkerUI: false, + + // Custom URL to redirect to when logging in is required + // This URL will need to handle the login process and redirect users back to LiveAtlas + customLoginUrl: null }, // Config version. Do not modify. diff --git a/src/index.d.ts b/src/index.d.ts index 07eddc5..acfc55b 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -126,6 +126,7 @@ interface LiveAtlasUIConfig { compactPlayerMarkers: boolean; disableContextMenu: boolean; disableMarkerUI: boolean; + customLoginUrl: string | null; } export type LiveAtlasUIElement = 'layers' | 'chat' | LiveAtlasSidebarSection; diff --git a/src/store/actions.ts b/src/store/actions.ts index 6c302b4..9acb5c0 100644 --- a/src/store/actions.ts +++ b/src/store/actions.ts @@ -205,7 +205,11 @@ export const actions: ActionTree & Actions = { if(data) { await state.currentMapProvider!.login(data); } else { - commit(MutationTypes.SHOW_UI_MODAL, 'login'); + if(state.ui.customLoginUrl) { + window.location.href = state.ui.customLoginUrl; + } else { + commit(MutationTypes.SHOW_UI_MODAL, 'login'); + } } }, diff --git a/src/store/mutations.ts b/src/store/mutations.ts index 7d56832..461d66a 100644 --- a/src/store/mutations.ts +++ b/src/store/mutations.ts @@ -142,6 +142,10 @@ export const mutations: MutationTree & Mutations = { state.ui.playersSearch = uiConfig.playersSearch; } + if(typeof uiConfig.customLoginUrl === 'string') { + state.ui.customLoginUrl = uiConfig.customLoginUrl; + } + state.servers = config.servers; if(state.currentServer && !state.servers.has(state.currentServer.id)) { diff --git a/src/store/state.ts b/src/store/state.ts index e1442f3..0dbafa4 100644 --- a/src/store/state.ts +++ b/src/store/state.ts @@ -88,6 +88,7 @@ export type State = { compactPlayerMarkers: boolean; disableContextMenu: boolean; disableMarkerUI: boolean; + customLoginUrl: string | null; screenWidth: number; screenHeight: number; @@ -230,6 +231,7 @@ export const state: State = { compactPlayerMarkers: false, disableContextMenu: false, disableMarkerUI: false, + customLoginUrl: null, screenWidth: window.innerWidth, screenHeight: window.innerHeight,