aboutsummaryrefslogtreecommitdiff
path: root/src/server/index.ts
diff options
context:
space:
mode:
authorSam Wilkins <35748010+samwilkins333@users.noreply.github.com>2019-10-17 04:01:15 -0400
committerSam Wilkins <35748010+samwilkins333@users.noreply.github.com>2019-10-17 04:01:15 -0400
commitdf7ed1e41472909e802116adaa285281ec7588ee (patch)
tree09aba4e851058d49edb779ea8646c7e741feee96 /src/server/index.ts
parente385c9b0285a1d015917eca49dfc190d9810c8d9 (diff)
streamlined
Diffstat (limited to 'src/server/index.ts')
-rw-r--r--src/server/index.ts18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/server/index.ts b/src/server/index.ts
index bba8fc292..81e236894 100644
--- a/src/server/index.ts
+++ b/src/server/index.ts
@@ -36,6 +36,8 @@ import InitializeServer from './Initialization';
import { Method, _success, _permission_denied, _error, _invalid, OnUnauthenticated } from './RouteManager';
import { command_line } from './ActionUtilities';
var findInFiles = require('find-in-files');
+import * as qs from 'query-string';
+
let youtubeApiKey: string;
@@ -537,21 +539,31 @@ async function PreliminaryFunctions() {
method: Method.GET,
subscription: [RouteStore.home, new RouteSubscriber("/doc").add("docId")],
onValidation: serve,
- onGuestAccess: serve
+ onUnauthenticated: ({ req, ...remaining }) => {
+ const { originalUrl: target } = req;
+ const sharing = qs.parse(qs.extract(req.originalUrl), { sort: false }).sharing === "true";
+ const docAccess = target.startsWith("/doc/");
+ if (sharing && docAccess) {
+ serve({ req, ...remaining });
+ }
+ }
});
router.addSupervisedRoute({
method: Method.GET,
subscription: RouteStore.getUserDocumentId,
onValidation: ({ res, user }) => res.send(user.userDocumentId),
- onRejection: ({ res }) => res.send(undefined)
+ onUnauthenticated: ({ res }) => _permission_denied(res)
});
router.addSupervisedRoute({
method: Method.GET,
subscription: RouteStore.getCurrUser,
onValidation: ({ res, user }) => { res.send(JSON.stringify(user)); },
- onRejection: ({ res }) => res.send(JSON.stringify({ id: "__guest__", email: "" }))
+ onUnauthenticated: ({ res }) => {
+ res.send(JSON.stringify({ id: "__guest__", email: "" }))
+ return true;
+ }
});
const ServicesApiKeyMap = new Map<string, string | undefined>([