mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-02-03 00:39:39 +00:00
Update plugins to only be enabled when ALLOW_PLUGINS=1 env variable is set or AllowPlugins: true in dev.js
This commit is contained in:
parent
50e84fc2d5
commit
e7e0056288
6 changed files with 37 additions and 17 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue