Skip to content

Commit

Permalink
Add option for custom login URL. Fixes JLyne#381.
Browse files Browse the repository at this point in the history
  • Loading branch information
JLyne committed Jun 17, 2022
1 parent 46c4e6d commit e37ed13
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ interface LiveAtlasUIConfig {
compactPlayerMarkers: boolean;
disableContextMenu: boolean;
disableMarkerUI: boolean;
customLoginUrl: string | null;
}

export type LiveAtlasUIElement = 'layers' | 'chat' | LiveAtlasSidebarSection;
Expand Down
6 changes: 5 additions & 1 deletion src/store/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,11 @@ export const actions: ActionTree<State, State> & 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');
}
}
},

Expand Down
4 changes: 4 additions & 0 deletions src/store/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ export const mutations: MutationTree<State> & 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)) {
Expand Down
2 changes: 2 additions & 0 deletions src/store/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export type State = {
compactPlayerMarkers: boolean;
disableContextMenu: boolean;
disableMarkerUI: boolean;
customLoginUrl: string | null;

screenWidth: number;
screenHeight: number;
Expand Down Expand Up @@ -230,6 +231,7 @@ export const state: State = {
compactPlayerMarkers: false,
disableContextMenu: false,
disableMarkerUI: false,
customLoginUrl: null,

screenWidth: window.innerWidth,
screenHeight: window.innerHeight,
Expand Down

0 comments on commit e37ed13

Please sign in to comment.