aboutsummaryrefslogtreecommitdiff
path: root/src/server/index.ts
diff options
context:
space:
mode:
authorlaurawilsonri <laura_wilson@brown.edu>2019-04-15 20:20:46 -0400
committerlaurawilsonri <laura_wilson@brown.edu>2019-04-15 20:20:46 -0400
commitb7a766aa5d53686e032b34d7213ad543108f12c3 (patch)
treed71854e091fa24997a30856d9ac9c937a6cd45d2 /src/server/index.ts
parent8b1026d357dd40fc4a00010739d99ffc9db08641 (diff)
parentff6ba4107aa33e021803399180b0d2844fc19d84 (diff)
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web into richTextEditor
Diffstat (limited to 'src/server/index.ts')
-rw-r--r--src/server/index.ts16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/server/index.ts b/src/server/index.ts
index a6fe6fa2c..3cbe1ca76 100644
--- a/src/server/index.ts
+++ b/src/server/index.ts
@@ -87,9 +87,11 @@ function addSecureRoute(method: Method,
...subscribers: string[]
) {
let abstracted = (req: express.Request, res: express.Response) => {
- const dashUser: DashUserModel = req.user;
- if (!dashUser) return onRejection(res);
- handler(dashUser, res, req);
+ if (req.user) {
+ handler(req.user, res, req);
+ } else {
+ onRejection(res);
+ }
};
subscribers.forEach(route => {
switch (method) {
@@ -246,17 +248,17 @@ function barReceived(guid: String) {
clients[guid.toString()] = new Client(guid.toString());
}
-function getField([id, callback]: [string, (result: any) => void]) {
- Database.Instance.getDocument(id, (result: any) =>
+function getField([id, callback]: [string, (result?: Transferable) => void]) {
+ Database.Instance.getDocument(id, (result?: Transferable) =>
callback(result ? result : undefined));
}
-function getFields([ids, callback]: [string[], (result: any) => void]) {
+function getFields([ids, callback]: [string[], (result: Transferable[]) => void]) {
Database.Instance.getDocuments(ids, callback);
}
function setField(socket: Socket, newValue: Transferable) {
- Database.Instance.update(newValue._id, newValue, () =>
+ Database.Instance.update(newValue.id, newValue, () =>
socket.broadcast.emit(MessageStore.SetField.Message, newValue));
}