mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Add in Features module to handle feature flags, and use it to cleanly turn off registration
This commit is contained in:
parent
b6289f03e3
commit
745ae8d081
3 changed files with 9 additions and 7 deletions
|
@ -14,6 +14,7 @@ PackageVersions = require "./PackageVersions"
|
||||||
htmlEncoder = new require("node-html-encoder").Encoder("numerical")
|
htmlEncoder = new require("node-html-encoder").Encoder("numerical")
|
||||||
fingerprints = {}
|
fingerprints = {}
|
||||||
Path = require 'path'
|
Path = require 'path'
|
||||||
|
Features = require "./Features"
|
||||||
|
|
||||||
jsPath =
|
jsPath =
|
||||||
if Settings.useMinifiedJs
|
if Settings.useMinifiedJs
|
||||||
|
@ -88,8 +89,9 @@ module.exports = (app, webRouter, privateApiRouter, publicApiRouter)->
|
||||||
publicApiRouter.use addSetContentDisposition
|
publicApiRouter.use addSetContentDisposition
|
||||||
|
|
||||||
webRouter.use (req, res, next)->
|
webRouter.use (req, res, next)->
|
||||||
req.externalAuthenticationSystemUsed = res.locals.externalAuthenticationSystemUsed = ->
|
req.externalAuthenticationSystemUsed = Features.externalAuthenticationSystemUsed
|
||||||
Settings.ldap? or Settings.saml?
|
res.locals.externalAuthenticationSystemUsed = Features.externalAuthenticationSystemUsed
|
||||||
|
req.hasFeature = res.locals.hasFeature = Features.hasFeature
|
||||||
next()
|
next()
|
||||||
|
|
||||||
webRouter.use (req, res, next)->
|
webRouter.use (req, res, next)->
|
||||||
|
|
|
@ -45,6 +45,7 @@ AnalyticsRouter = require('./Features/Analytics/AnalyticsRouter')
|
||||||
AnnouncementsController = require("./Features/Announcements/AnnouncementsController")
|
AnnouncementsController = require("./Features/Announcements/AnnouncementsController")
|
||||||
LabelsController = require('./Features/Labels/LabelsController')
|
LabelsController = require('./Features/Labels/LabelsController')
|
||||||
TokenAccessController = require('./Features/TokenAccess/TokenAccessController')
|
TokenAccessController = require('./Features/TokenAccess/TokenAccessController')
|
||||||
|
Features = require('./infrastructure/Features')
|
||||||
|
|
||||||
logger = require("logger-sharelatex")
|
logger = require("logger-sharelatex")
|
||||||
_ = require("underscore")
|
_ = require("underscore")
|
||||||
|
@ -63,10 +64,9 @@ module.exports = class Router
|
||||||
webRouter.get '/logout', UserController.logout
|
webRouter.get '/logout', UserController.logout
|
||||||
webRouter.get '/restricted', AuthorizationMiddlewear.restricted
|
webRouter.get '/restricted', AuthorizationMiddlewear.restricted
|
||||||
|
|
||||||
# Left as a placeholder for implementing a public register page
|
if Features.hasFeature('registration')
|
||||||
webRouter.get '/register', UserPagesController.registerPage
|
webRouter.get '/register', UserPagesController.registerPage
|
||||||
AuthenticationController.addEndpointToLoginWhitelist '/register'
|
AuthenticationController.addEndpointToLoginWhitelist '/register'
|
||||||
|
|
||||||
|
|
||||||
EditorRouter.apply(webRouter, privateApiRouter)
|
EditorRouter.apply(webRouter, privateApiRouter)
|
||||||
CollaboratorsRouter.apply(webRouter, privateApiRouter)
|
CollaboratorsRouter.apply(webRouter, privateApiRouter)
|
||||||
|
|
|
@ -54,7 +54,7 @@ nav.navbar.navbar-default
|
||||||
// logged out
|
// logged out
|
||||||
if !getSessionUser()
|
if !getSessionUser()
|
||||||
// register link
|
// register link
|
||||||
if !externalAuthenticationSystemUsed()
|
if hasFeature('registration')
|
||||||
li
|
li
|
||||||
a(href="/register") #{translate('register')}
|
a(href="/register") #{translate('register')}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue