aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
Diffstat (limited to 'src/server')
-rw-r--r--src/server/authentication/controllers/user.ts16
-rw-r--r--src/server/index.ts14
2 files changed, 14 insertions, 16 deletions
diff --git a/src/server/authentication/controllers/user.ts b/src/server/authentication/controllers/user.ts
index 72fdd5137..554781409 100644
--- a/src/server/authentication/controllers/user.ts
+++ b/src/server/authentication/controllers/user.ts
@@ -5,7 +5,6 @@ import { IVerifyOptions } from "passport-local";
import "../config/passport";
import * as request from "express-validator";
const flash = require("express-flash");
-import * as path from 'path'
import * as session from "express-session";
import * as pug from 'pug';
@@ -18,17 +17,6 @@ export let getEntry = (req: Request, res: Response) => {
res.redirect("/login");
}
-export let getHome = (req: Request, res: Response) => {
- // 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'));
-}
-
/**
* GET /signup
* Directs user to the signup page
@@ -38,7 +26,7 @@ export let getSignup = (req: Request, res: Response) => {
if (req.user) {
let user = req.user;
console.log(user);
- return res.redirect("/");
+ return res.redirect("/home");
}
res.render("signup.pug", {
title: "Sign Up"
@@ -104,7 +92,7 @@ export let postSignup = (req: Request, res: Response, next: NextFunction) => {
*/
export let getLogin = (req: Request, res: Response) => {
if (req.user) {
- return res.redirect("/");
+ return res.redirect("/home");
}
res.render("login.pug", {
title: "Log In"
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