Просмотр исходного кода

Merge pull request #2617 from overleaf/ho-open-site-for-admins

allow site to be accessible to admins when closed

GitOrigin-RevId: 71bdf329ce2a4e41533b2a65f45190277ea72dbb
Timothée Alby 6 лет назад
Родитель
Сommit
b94e1791e0

+ 5 - 0
services/web/app/src/infrastructure/Server.js

@@ -182,6 +182,11 @@ if (app.get('env') === 'production') {
 webRouter.use(function(req, res, next) {
   if (Settings.siteIsOpen) {
     next()
+  } else if (
+    AuthenticationController.getSessionUser(req) &&
+    AuthenticationController.getSessionUser(req).isAdmin
+  ) {
+    next()
   } else {
     res.status(503)
     res.render('general/closed', { title: 'maintenance' })

+ 3 - 0
services/web/app/views/project/list.pug

@@ -23,6 +23,9 @@ block content
 		- if(typeof(suppressSystemMessages) == "undefined")
 			script.
 				window.systemMessages = !{StringHelper.stringifyJsonForScript(systemMessages)};
+			- if(settings.siteIsOpen == false && getSessionUser() && getSessionUser().isAdmin)
+				script.
+					window.systemMessages.push({content: "SITE IS CLOSED TO PUBLIC. OPEN ONLY FOR SITE ADMINS", _id:"siteclosed"})
 
 			.system-messages(
 				ng-cloak