Skip to content

Commit

Permalink
🚨 Adds null check for appConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
Lissy93 committed Aug 18, 2021
1 parent cd4956b commit a95c91a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/components/Settings/SettingsContainer.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<template>
<section>
<p>{{ getUserState }}</p>
<SearchBar ref="SearchBar"
@user-is-searchin="userIsTypingSomething"
v-if="searchVisible"
Expand All @@ -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()"
Expand Down Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/Auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

0 comments on commit a95c91a

Please sign in to comment.