💥 Major structural modifications to Auth object

This commit is contained in:
Alicia Sykes
2021-08-21 20:38:58 +01:00
parent 053c55c8e3
commit 7608fba2f5
5 changed files with 86 additions and 45 deletions

View File

@@ -25,12 +25,14 @@ Vue.use(Router);
/* Checks if guest mode is enabled in appConfig */
const isGuestEnabled = () => {
if (!config || !config.appConfig) return false;
return config.appConfig.enableGuestAccess || false;
if (config.appConfig.enableGuestAccess) return true;
return config.appConfig.auth.enableGuestAccess || false;
};
/* Returns true if user is already authenticated, or if auth is not enabled */
const isAuthenticated = () => {
const users = config.appConfig.auth;
const auth = config.appConfig.auth || {};
const users = Array.isArray(auth) ? auth : auth.users || [];
return (!users || users.length === 0 || isLoggedIn() || isGuestEnabled());
};