🚨 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>
<section>
<p>{{ getUserState }}</p>
<SearchBar ref="SearchBar"
@user-is-searchin="userIsTypingSomething"
v-if="searchVisible"
@ -14,7 +13,7 @@
<ItemSizeSelector :iconSize="iconSize" @iconSizeUpdated="updateIconSize" />
<ConfigLauncher :sections="sections" :pageInfo="pageInfo" :appConfig="appConfig"
@modalChanged="modalChanged" />
<AuthButtons v-if="getUserState != 'noone'" :userType="getUserState" />
<AuthButtons v-if="userState != 'noone'" :userType="userState" />
</div>
<div :class="`show-hide-container ${settingsVisible? 'hide-btn' : 'show-btn'}`">
<button @click="toggleSettingsVisibility()"
@ -114,8 +113,8 @@ export default {
* 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
*/
getUserState() {
return getUserState(this.appConfig);
userState() {
return getUserState(this.appConfig || {});
},
},
data() {

View File

@ -127,6 +127,6 @@ export const getUserState = (appConfig) => {
const users = appConfig.auth || []; // Get auth object
if (!isAuthEnabled(users)) return notConfigured; // No auth enabled
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;
};