diff options
author | Sam Wilkins <samwilkins333@gmail.com> | 2019-02-24 15:47:07 -0500 |
---|---|---|
committer | Sam Wilkins <samwilkins333@gmail.com> | 2019-02-24 15:47:07 -0500 |
commit | b441bb2b67f10ae1b83363d158a0ac1591f63e51 (patch) | |
tree | 8bc624059233d71095c896c3ebf776e28fa2cfc6 /src/server/index.ts | |
parent | 28fc26cec5faa0ac1f70a37aa6a23d6cb2d61f03 (diff) |
rough ui finished
Diffstat (limited to 'src/server/index.ts')
-rw-r--r-- | src/server/index.ts | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/server/index.ts b/src/server/index.ts index d097b4aec..7189b32a0 100644 --- a/src/server/index.ts +++ b/src/server/index.ts @@ -16,7 +16,7 @@ import { ObjectID } from 'mongodb'; import { Document } from '../fields/Document'; import * as io from 'socket.io' import * as passportConfig from './authentication/config/passport'; -import { getLogin, postLogin, getSignup, postSignup, getLogout, getEntry, getHome } from './authentication/controllers/user'; +import { getLogin, postLogin, getSignup, postSignup, getLogout, getEntry } from './authentication/controllers/user'; const config = require('../../webpack.config'); const compiler = webpack(config); const port = 1050; // default port to listen @@ -32,6 +32,7 @@ const MongoStore = require('connect-mongo')(session); const mongoose = require('mongoose'); const bluebird = require('bluebird'); import { performance } from 'perf_hooks' +import * as path from 'path' const mongoUrl = 'mongodb://localhost:27017/Dash'; // mongoose.Promise = bluebird; @@ -77,7 +78,16 @@ app.use((req, res, next) => { // functions in the exports of user.ts // /home defines destination after a successful log in -app.get("/home", getHome); +app.get("/home", (req, res) => { + // if user is not logged in, redirect to log in page + if (!req.user) { + res.redirect("/login"); + return; + } + // otherwise, connect them to Dash + // TODO: store and manage users' workspaces + res.sendFile(path.join(__dirname, '../../deploy/index.html')); +}); // anyone attempting to navigate to localhost at this port will // first have to login |