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