🚨 Adds null check for appConfig

This commit is contained in:
Alicia Sykes 2021-08-18 21:35:21 +01:00
parent cd4956b1df
commit a95c91a380
2 changed files with 4 additions and 5 deletions

View File

@ -1,6 +1,5 @@
<template> <template>
<section> <section>
<p>{{ getUserState }}</p>
<SearchBar ref="SearchBar" <SearchBar ref="SearchBar"
@user-is-searchin="userIsTypingSomething" @user-is-searchin="userIsTypingSomething"
v-if="searchVisible" v-if="searchVisible"
@ -14,7 +13,7 @@
<ItemSizeSelector :iconSize="iconSize" @iconSizeUpdated="updateIconSize" /> <ItemSizeSelector :iconSize="iconSize" @iconSizeUpdated="updateIconSize" />
<ConfigLauncher :sections="sections" :pageInfo="pageInfo" :appConfig="appConfig" <ConfigLauncher :sections="sections" :pageInfo="pageInfo" :appConfig="appConfig"
@modalChanged="modalChanged" /> @modalChanged="modalChanged" />
<AuthButtons v-if="getUserState != 'noone'" :userType="getUserState" /> <AuthButtons v-if="userState != 'noone'" :userType="userState" />
</div> </div>
<div :class="`show-hide-container ${settingsVisible? 'hide-btn' : 'show-btn'}`"> <div :class="`show-hide-container ${settingsVisible? 'hide-btn' : 'show-btn'}`">
<button @click="toggleSettingsVisibility()" <button @click="toggleSettingsVisibility()"
@ -114,8 +113,8 @@ export default {
* Note that if auth is enabled, but not guest access, and user not logged in, * Note that if auth is enabled, but not guest access, and user not logged in,
* then they will never be able to view the homepage, so no button needed * then they will never be able to view the homepage, so no button needed
*/ */
getUserState() { userState() {
return getUserState(this.appConfig); return getUserState(this.appConfig || {});
}, },
}, },
data() { data() {

View File

@ -127,6 +127,6 @@ export const getUserState = (appConfig) => {
const users = appConfig.auth || []; // Get auth object const users = appConfig.auth || []; // Get auth object
if (!isAuthEnabled(users)) return notConfigured; // No auth enabled if (!isAuthEnabled(users)) return notConfigured; // No auth enabled
if (isLoggedIn(users)) return loggedIn; // User is logged in if (isLoggedIn(users)) return loggedIn; // User is logged in
if (isGuestAccessEnabled(appConfig || {})) return guestAccess; // Guest is viewing if (isGuestAccessEnabled(appConfig)) return guestAccess; // Guest is viewing
return notConfigured; return notConfigured;
}; };