diff --git a/client/components/app/ConfigSideNav.vue b/client/components/app/ConfigSideNav.vue index 9700cc1b..df6778c3 100644 --- a/client/components/app/ConfigSideNav.vue +++ b/client/components/app/ConfigSideNav.vue @@ -109,13 +109,16 @@ export default { id: 'config-authentication', title: this.$strings.HeaderAuthentication, path: '/config/authentication' - }, - { + } + ] + + if (this.$store.state.pluginsEnabled) { + configRoutes.push({ id: 'config-plugins', title: 'Plugins', path: '/config/plugins' - } - ] + }) + } if (this.currentLibraryId) { configRoutes.push({ diff --git a/client/pages/login.vue b/client/pages/login.vue index 3a2f165a..f9943b0c 100644 --- a/client/pages/login.vue +++ b/client/pages/login.vue @@ -170,7 +170,10 @@ export default { this.$store.commit('setServerSettings', serverSettings) this.$store.commit('setSource', Source) this.$store.commit('libraries/setEReaderDevices', ereaderDevices) - this.$store.commit('setPlugins', plugins) + if (plugins !== undefined) { + this.$store.commit('setPlugins', plugins) + } + this.$setServerLanguageCode(serverSettings.language) if (serverSettings.chromecastEnabled) { diff --git a/client/store/index.js b/client/store/index.js index 66fc33b4..f3c8822e 100644 --- a/client/store/index.js +++ b/client/store/index.js @@ -29,7 +29,8 @@ export const state = () => ({ innerModalOpen: false, lastBookshelfScrollData: {}, routerBasePath: '/', - plugins: [] + plugins: [], + pluginsEnabled: false }) export const getters = { @@ -64,6 +65,7 @@ export const getters = { return state.serverSettings.homeBookshelfView }, getPluginExtensions: (state) => (target) => { + if (!state.pluginsEnabled) return [] return state.plugins .map((pext) => { const extensionsMatchingTarget = pext.extensions?.filter((ext) => ext.target === target) || [] @@ -256,5 +258,6 @@ export const mutations = { }, setPlugins(state, val) { state.plugins = val + state.pluginsEnabled = true } } diff --git a/index.js b/index.js index 9a0be347..2ca70cce 100644 --- a/index.js +++ b/index.js @@ -13,6 +13,7 @@ if (isDev) { if (devEnv.SkipBinariesCheck) process.env.SKIP_BINARIES_CHECK = '1' if (devEnv.AllowIframe) process.env.ALLOW_IFRAME = '1' if (devEnv.BackupPath) process.env.BACKUP_PATH = devEnv.BackupPath + if (devEnv.AllowPlugins) process.env.ALLOW_PLUGINS = '1' process.env.SOURCE = 'local' process.env.ROUTER_BASE_PATH = devEnv.RouterBasePath || '' } diff --git a/server/Auth.js b/server/Auth.js index c11b3372..089263f0 100644 --- a/server/Auth.js +++ b/server/Auth.js @@ -935,14 +935,12 @@ class Auth { */ async getUserLoginResponsePayload(user) { const libraryIds = await Database.libraryModel.getAllLibraryIds() - return { - user: user.toOldJSONForBrowser(), - userDefaultLibraryId: user.getDefaultLibraryId(libraryIds), - serverSettings: Database.serverSettings.toJSONForBrowser(), - ereaderDevices: Database.emailSettings.getEReaderDevices(user), + + let plugins = undefined + if (process.env.ALLOW_PLUGINS === '1') { // TODO: Should be better handled by the PluginManager // restrict plugin extensions that are not allowed for the user type - plugins: this.pluginManifests.map((manifest) => { + plugins = this.pluginManifests.map((manifest) => { const manifestExtensions = (manifest.extensions || []).filter((ext) => { if (ext.restrictToAccountTypes?.length) { return ext.restrictToAccountTypes.includes(user.type) @@ -950,7 +948,15 @@ class Auth { return true }) return { ...manifest, extensions: manifestExtensions } - }), + }) + } + + return { + user: user.toOldJSONForBrowser(), + userDefaultLibraryId: user.getDefaultLibraryId(libraryIds), + serverSettings: Database.serverSettings.toJSONForBrowser(), + ereaderDevices: Database.emailSettings.getEReaderDevices(user), + plugins, Source: global.Source } } diff --git a/server/Server.js b/server/Server.js index 87f22fb2..7a6ba15b 100644 --- a/server/Server.js +++ b/server/Server.js @@ -151,10 +151,14 @@ class Server { }) } - // Initialize plugins - await PluginManager.init() - // TODO: Prevents circular dependency for SocketAuthority - this.auth.pluginManifests = PluginManager.pluginManifests + if (process.env.ALLOW_PLUGINS === '1') { + Logger.info(`[Server] Experimental plugin support enabled`) + + // Initialize plugins + await PluginManager.init() + // TODO: Prevents circular dependency for SocketAuthority + this.auth.pluginManifests = PluginManager.pluginManifests + } } /**