aboutsummaryrefslogtreecommitdiff
path: root/src/server/index.ts
diff options
context:
space:
mode:
authoranika-ahluwalia <anika.ahluwalia@gmail.com>2020-04-18 17:56:30 -0500
committeranika-ahluwalia <anika.ahluwalia@gmail.com>2020-04-18 17:56:30 -0500
commit04e2cdc30dd71cccb066f713a93cdc4d3bbd169c (patch)
treeebacc25b4b99ac74b4bf79c12d0ae17a46033b0b /src/server/index.ts
parenta261ab5e9697277bec029803f1fa0c890f0c8fd5 (diff)
parent9f8e76451b807ed8f51ef32aab9b2255dfccd525 (diff)
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web into script_documents
Diffstat (limited to 'src/server/index.ts')
-rw-r--r--src/server/index.ts10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/server/index.ts b/src/server/index.ts
index 8b040c926..f26c8a6ab 100644
--- a/src/server/index.ts
+++ b/src/server/index.ts
@@ -106,12 +106,17 @@ function routeSetter({ isRelease, addSupervisedRoute, logRegistrationOutcome }:
method: Method.GET,
subscription: ["/home", new RouteSubscriber("doc").add("docId")],
secureHandler: serve,
- publicHandler: ({ req, ...remaining }) => {
+ publicHandler: ({ req, res, ...remaining }) => {
const { originalUrl: target } = req;
const sharing = qs.parse(qs.extract(req.originalUrl), { sort: false }).sharing === "true";
const docAccess = target.startsWith("/doc/");
+ // since this is the public handler, there's no meaning of '/home' to speak of
+ // since there's no user logged in, so the only viable operation
+ // for a guest is to look at a shared document
if (sharing && docAccess) {
- serve({ req, ...remaining });
+ serve({ req, res, ...remaining });
+ } else {
+ res.redirect("/login");
}
}
});
@@ -148,5 +153,6 @@ export async function launchServer() {
if (process.env.RELEASE) {
(sessionAgent = new DashSessionAgent()).launch();
} else {
+ (Database.Instance as Database.Database).doConnect();
launchServer();
}