Merge pull request #1472 from sharelatex/ew-add-close-site-and-private-disconnect-route

Add close site setting and private disconnect all users route

GitOrigin-RevId: d078c053ba4e5f5c048f30f2a6d509966736b3e0
This commit is contained in:
Ersun Warncke 2019-02-06 10:06:40 -04:00 committed by sharelatex
parent c51461da09
commit 81e3db260c
5 changed files with 38 additions and 3 deletions

View file

@ -42,8 +42,6 @@ AuthenticationController = require "../Features/Authentication/AuthenticationCon
metrics.event_loop?.monitor(logger)
Settings.editorIsOpen ||= true
if Settings.cacheStaticAssets
staticCacheAge = (oneDayInMilliseconds * 365)
else
@ -135,6 +133,13 @@ app.use (req, res, next)->
crawlerLogger.log(req)
next()
webRouter.use (req, res, next) ->
if Settings.siteIsOpen
next()
else
res.status(503)
res.render("general/closed", {title:"maintenance"})
webRouter.use (req, res, next) ->
if Settings.editorIsOpen
next()

View file

@ -425,6 +425,8 @@ module.exports = class Router
webRouter.post '/admin/messages', AuthorizationMiddlewear.ensureUserIsSiteAdmin, AdminController.createMessage
webRouter.post '/admin/messages/clear', AuthorizationMiddlewear.ensureUserIsSiteAdmin, AdminController.clearMessages
privateApiRouter.post '/disconnectAllUsers', AdminController.dissconectAllUsers
privateApiRouter.get '/perfTest', (req,res)->
res.send("hello")

View file

@ -8,7 +8,7 @@ block content
.page-header
h1 Maintenance
p
| Sorry, ShareLaTeX is briefly down for maintenance.
| Sorry, #{settings.appName} is briefly down for maintenance.
| We should be back within minutes, but if not, or you have
| an urgent request, please contact us at
|  #{settings.adminEmail}

View file

@ -350,6 +350,12 @@ module.exports = settings =
# public projects, /learn, /templates, about pages, etc.
allowPublicAccess: if process.env["SHARELATEX_ALLOW_PUBLIC_ACCESS"] == 'true' then true else false
# editor should be open by default
editorIsOpen: if process.env["EDITOR_OPEN"] == 'false' then false else true
# site should be open by default
siteIsOpen: if process.env["SITE_OPEN"] == 'false' then false else true
# Use a single compile directory for all users in a project
# (otherwise each user has their own directory)
# disablePerUserCompiles: true

View file

@ -0,0 +1,22 @@
Settings = require "settings-sharelatex"
chai = require "chai"
request = require "./helpers/request"
describe "siteIsOpen", ->
describe "when siteIsOpen is default (true)", ->
it "should get page", (done) ->
request.get "/login", (error, response, body) ->
response.statusCode.should.equal 200
done()
describe "when siteIsOpen is false", ->
beforeEach ->
Settings.siteIsOpen = false
afterEach ->
Settings.siteIsOpen = true
it "should return maintenance page", (done) ->
request.get "/login", (error, response) ->
response.statusCode.should.equal 503
done()