Refactor use of .env variables after Moriz suggestions

This commit is contained in:
Wolfgang Huß 2021-03-19 13:23:15 +01:00
parent a63eb04385
commit 4c8fb83dcd
4 changed files with 8 additions and 10 deletions

View File

@ -82,8 +82,8 @@ const options = {
SUPPORT_URL: links.SUPPORT,
APPLICATION_NAME: metadata.APPLICATION_NAME,
ORGANIZATION_URL: links.ORGANIZATION,
PUBLIC_REGISTRATION: env.PUBLIC_REGISTRATION === 'true', // because env booleans are given as string in differenz to the webapp
INVITE_REGISTRATION: env.INVITE_REGISTRATION === 'true', // because env booleans are given as string in differenz to the webapp
PUBLIC_REGISTRATION: env.PUBLIC_REGISTRATION === 'true' || false,
INVITE_REGISTRATION: env.INVITE_REGISTRATION !== 'false', // default = true
}
// Check if all required configs are present

View File

@ -29,8 +29,8 @@ const sentry = {
const options = {
VERSION: process.env.VERSION || pkg.version,
DESCRIPTION: process.env.DESCRIPTION || pkg.description,
PUBLIC_REGISTRATION: process.env.PUBLIC_REGISTRATION, // because env booleans are given as booleans and not as strings in differenz to the backend
INVITE_REGISTRATION: process.env.INVITE_REGISTRATION, // because env booleans are given as booleans and not as strings in differenz to the backend
PUBLIC_REGISTRATION: process.env.PUBLIC_REGISTRATION === 'true' || false,
INVITE_REGISTRATION: process.env.INVITE_REGISTRATION !== 'false', // default = true
// Cookies
COOKIE_EXPIRE_TIME: process.env.COOKIE_EXPIRE_TIME || 730, // Two years by default
COOKIE_HTTPS_ONLY: process.env.COOKIE_HTTPS_ONLY || process.env.NODE_ENV === 'production', // ensure true in production if not set explicitly

View File

@ -27,7 +27,7 @@ export default {
},
env: {
release: CONFIG.VERSION,
...CONFIG,
// pages which do NOT require a login
publicPages: [
'login',

View File

@ -25,16 +25,14 @@ export default {
nonce,
},
},
publicRegistration: this.$env.PUBLIC_REGISTRATION === 'true', // for 'false' in .env PUBLIC_REGISTRATION is of type undefined and not(!) boolean false, because of internal handling
inviteRegistration: this.$env.INVITE_REGISTRATION === 'true', // for 'false' in .env INVITE_REGISTRATION is of type undefined and not(!) boolean false, because of internal handling
}
},
asyncData({ app, store, redirect }) {
asyncData({ store, redirect }) {
if (store.getters['auth/isLoggedIn']) {
redirect('/')
}
return {
publicRegistration: app.$env.PUBLIC_REGISTRATION,
inviteRegistration: app.$env.INVITE_REGISTRATION,
}
},
computed: {
registrationType() {