mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-02 08:29:37 -05:00
0596e8d25c
[web] remove legacy registration aka the public-registration module GitOrigin-RevId: 5cbb7ecbc7da5cd0617bd1abd1f5c6eef4c05b3f
101 lines
3.2 KiB
JavaScript
101 lines
3.2 KiB
JavaScript
const _ = require('lodash')
|
|
const Settings = require('@overleaf/settings')
|
|
|
|
const supportModuleAvailable = Settings.moduleImportSequence.includes('support')
|
|
|
|
const symbolPaletteModuleAvailable =
|
|
Settings.moduleImportSequence.includes('symbol-palette')
|
|
|
|
const trackChangesModuleAvailable =
|
|
Settings.moduleImportSequence.includes('track-changes')
|
|
|
|
/**
|
|
* @typedef {Object} Settings
|
|
* @property {Object | undefined} apis
|
|
* @property {Object | undefined} apis.linkedUrlProxy
|
|
* @property {string | undefined} apis.linkedUrlProxy.url
|
|
* @property {Object | undefined} apis.references
|
|
* @property {string | undefined} apis.references.url
|
|
* @property {boolean | undefined} enableGithubSync
|
|
* @property {boolean | undefined} enableGitBridge
|
|
* @property {boolean | undefined} enableHomepage
|
|
* @property {boolean | undefined} enableSaml
|
|
* @property {boolean | undefined} ldap
|
|
* @property {boolean | undefined} oauth
|
|
* @property {Object | undefined} overleaf
|
|
* @property {Object | undefined} overleaf.oauth
|
|
* @property {boolean | undefined} saml
|
|
*/
|
|
|
|
const Features = {
|
|
/**
|
|
* @returns {boolean}
|
|
*/
|
|
externalAuthenticationSystemUsed() {
|
|
return (
|
|
(Boolean(Settings.ldap) && Boolean(Settings.ldap.enable)) ||
|
|
(Boolean(Settings.saml) && Boolean(Settings.saml.enable)) ||
|
|
Boolean(Settings.overleaf)
|
|
)
|
|
},
|
|
|
|
/**
|
|
* Whether a feature is enabled in the appliation's configuration
|
|
*
|
|
* @param {string} feature
|
|
* @returns {boolean}
|
|
*/
|
|
hasFeature(feature) {
|
|
switch (feature) {
|
|
case 'saas':
|
|
return Boolean(Settings.overleaf)
|
|
case 'homepage':
|
|
return Boolean(Settings.enableHomepage)
|
|
case 'registration-page':
|
|
return (
|
|
!Features.externalAuthenticationSystemUsed() ||
|
|
Boolean(Settings.overleaf)
|
|
)
|
|
case 'registration':
|
|
return Boolean(Settings.overleaf)
|
|
case 'github-sync':
|
|
return Boolean(Settings.enableGithubSync)
|
|
case 'git-bridge':
|
|
return Boolean(Settings.enableGitBridge)
|
|
case 'oauth':
|
|
return Boolean(Settings.oauth)
|
|
case 'templates-server-pro':
|
|
return Boolean(Settings.templates)
|
|
case 'affiliations':
|
|
case 'analytics':
|
|
return Boolean(_.get(Settings, ['apis', 'v1', 'url']))
|
|
case 'overleaf-integration':
|
|
return Boolean(Settings.overleaf)
|
|
case 'references':
|
|
return Boolean(_.get(Settings, ['apis', 'references', 'url']))
|
|
case 'saml':
|
|
return Boolean(Settings.enableSaml)
|
|
case 'linked-project-file':
|
|
return Boolean(Settings.enabledLinkedFileTypes.includes('project_file'))
|
|
case 'linked-project-output-file':
|
|
return Boolean(
|
|
Settings.enabledLinkedFileTypes.includes('project_output_file')
|
|
)
|
|
case 'link-url':
|
|
return Boolean(
|
|
_.get(Settings, ['apis', 'linkedUrlProxy', 'url']) &&
|
|
Settings.enabledLinkedFileTypes.includes('url')
|
|
)
|
|
case 'support':
|
|
return supportModuleAvailable
|
|
case 'symbol-palette':
|
|
return symbolPaletteModuleAvailable
|
|
case 'track-changes':
|
|
return trackChangesModuleAvailable
|
|
default:
|
|
throw new Error(`unknown feature: ${feature}`)
|
|
}
|
|
},
|
|
}
|
|
|
|
module.exports = Features
|