diff --git a/src/App.vue b/src/App.vue index 662060b..5084586 100644 --- a/src/App.vue +++ b/src/App.vue @@ -56,9 +56,9 @@ export default defineComponent({ chatBoxEnabled = computed(() => store.state.components.chatBox), chatVisible = computed(() => store.state.ui.visibleElements.has('chat')), - loginEnabled = computed(() => store.state.components.login), //Whether logging in is enabled for the current server loggedIn = computed(() => store.state.loggedIn), //Whether the user is currently logged in - loginRequired = ref(false), //Whether logging is required to view the current server + loginRequired = computed(() => store.state.loginRequired), //Whether logging is required to view the current server + loginEnabled = computed(() => store.state.components.login || loginRequired.value), //Whether logging in is enabled for the current server //Hide the login modal if we are logged out on a login-required server, but the server list is open //Allows switching servers without the modal overlapping @@ -79,8 +79,6 @@ export default defineComponent({ await store.dispatch(ActionTypes.LOAD_CONFIGURATION, undefined); await store.dispatch(ActionTypes.START_UPDATES, undefined); - loginRequired.value = false; - requestAnimationFrame(() => { hideSplash(); @@ -96,9 +94,8 @@ export default defineComponent({ return; } - //Logging in is required, show login modal - if(e.message === 'login-required') { - loginRequired.value = true; + //Logging in is required + if(loginRequired.value) { return; } @@ -211,6 +208,8 @@ export default defineComponent({ store.commit(MutationTypes.SHOW_UI_MODAL, 'login'); notify('Login required'); showSplashError('Login required', true, 1); + } else { + store.commit(MutationTypes.HIDE_UI_MODAL, 'login'); } }) diff --git a/src/providers/DynmapMapProvider.ts b/src/providers/DynmapMapProvider.ts index 9301f54..1f66288 100644 --- a/src/providers/DynmapMapProvider.ts +++ b/src/providers/DynmapMapProvider.ts @@ -629,8 +629,7 @@ export default class DynmapMapProvider extends MapProvider { const response = await DynmapMapProvider.getJSON(this.config.dynmap!.configuration, this.configurationAbort.signal); if(response.error === 'login-required') { - this.store.commit(MutationTypes.SET_LOGGED_IN, false); - this.store.commit(MutationTypes.SET_COMPONENTS, {login: true}); + this.store.commit(MutationTypes.SET_LOGIN_REQUIRED, true); } if (response.error) { @@ -813,7 +812,7 @@ export default class DynmapMapProvider extends MapProvider { async login(data: any) { const store = useStore(); - if (!store.state.components.login) { + if (!store.state.components.login && !store.state.loginRequired) { return Promise.reject(store.state.messages.loginErrorDisabled); } @@ -852,7 +851,7 @@ export default class DynmapMapProvider extends MapProvider { async logout() { const store = useStore(); - if (!store.state.components.login) { + if (!store.state.components.login && !store.state.loginRequired) { return Promise.reject(store.state.messages.loginErrorDisabled); } @@ -870,7 +869,7 @@ export default class DynmapMapProvider extends MapProvider { async register(data: any) { const store = useStore(); - if (!store.state.components.login) { + if (!store.state.components.login && !store.state.loginRequired) { return Promise.reject(store.state.messages.loginErrorDisabled); } diff --git a/src/providers/Pl3xmapMapProvider.ts b/src/providers/Pl3xmapMapProvider.ts index a2cc20e..40a8770 100644 --- a/src/providers/Pl3xmapMapProvider.ts +++ b/src/providers/Pl3xmapMapProvider.ts @@ -385,9 +385,6 @@ export default class Pl3xmapMapProvider extends MapProvider { this.store.commit(MutationTypes.SET_SERVER_MESSAGES, Pl3xmapMapProvider.buildMessagesConfig(response)); this.store.commit(MutationTypes.SET_WORLDS, this.buildWorlds(response, worldResponses)); this.store.commit(MutationTypes.SET_COMPONENTS, Pl3xmapMapProvider.buildComponents(response)); - - //Pl3xmap has no login functionality - this.store.commit(MutationTypes.SET_LOGGED_IN, false); } async populateWorld(world: LiveAtlasWorldDefinition) { diff --git a/src/store/mutation-types.ts b/src/store/mutation-types.ts index 418e873..19abcd4 100644 --- a/src/store/mutation-types.ts +++ b/src/store/mutation-types.ts @@ -59,5 +59,6 @@ export enum MutationTypes { TOGGLE_SIDEBAR_SECTION_COLLAPSED_STATE = 'toggleSidebarSectionCollapsedState', SET_LOGGED_IN = 'setLoggedIn', + SET_LOGIN_REQUIRED = 'setLoginRequired', RESET = 'reset' } diff --git a/src/store/mutations.ts b/src/store/mutations.ts index 1baa763..4a7d128 100644 --- a/src/store/mutations.ts +++ b/src/store/mutations.ts @@ -92,6 +92,7 @@ export type Mutations = { [MutationTypes.TOGGLE_SIDEBAR_SECTION_COLLAPSED_STATE](state: S, section: LiveAtlasSidebarSection): void [MutationTypes.SET_LOGGED_IN](state: S, payload: boolean): void + [MutationTypes.SET_LOGIN_REQUIRED](state: S, payload: boolean): void [MutationTypes.RESET](state: S): void } @@ -620,6 +621,10 @@ export const mutations: MutationTree & Mutations = { state.loggedIn = payload; }, + [MutationTypes.SET_LOGIN_REQUIRED](state: State, payload: boolean): void { + state.loginRequired = payload; + }, + //Cleanup for switching servers or reloading the configuration [MutationTypes.RESET](state: State): void { state.followTarget = undefined; @@ -661,5 +666,8 @@ export const mutations: MutationTree & Mutations = { state.ui.visibleModal = undefined; state.chat.messages = []; + + state.loggedIn = false; + state.loginRequired = false; } }