diff options
| author | Tyler Schicke <tyler_schicke@brown.edu> | 2019-02-25 00:55:03 -0500 |
|---|---|---|
| committer | Tyler Schicke <tyler_schicke@brown.edu> | 2019-02-25 00:55:03 -0500 |
| commit | 62e06a2c9ce5054777a7a790e5b03b96d3cd6425 (patch) | |
| tree | 4e5c4cb1851ba221c1c3dab4e46ee4db3b18b344 /src/server/authentication | |
| parent | 3113bd7dfee404eea113633f97027a2370f8d817 (diff) | |
| parent | a160304a54ee0219f48faee8a7402503f2160902 (diff) | |
Merge branch 'authentication' of github-tsch-brown:browngraphicslab/Dash-Web into authentication
Diffstat (limited to 'src/server/authentication')
| -rw-r--r-- | src/server/authentication/controllers/user.ts | 8 | ||||
| -rw-r--r-- | src/server/authentication/models/User.ts | 1 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/server/authentication/controllers/user.ts b/src/server/authentication/controllers/user.ts index 93986adf8..a496959d1 100644 --- a/src/server/authentication/controllers/user.ts +++ b/src/server/authentication/controllers/user.ts @@ -12,6 +12,8 @@ import * as pug from 'pug'; * GET / * Whenever a user navigates to the root of Dash * (doesn't specify a sub-route), redirect to login. + * If the user is already signed in, it will effectively + * automatically redirect them to /home instead */ export let getEntry = (req: Request, res: Response) => { res.redirect("/login"); @@ -29,6 +31,7 @@ export let getSignup = (req: Request, res: Response) => { } res.render("signup.pug", { title: "Sign Up", + user: req.user, errors: req.flash("Unable to facilitate sign up. Please try again.") }); }; @@ -61,7 +64,9 @@ export let postSignup = (req: Request, res: Response, next: NextFunction) => { const user = new User({ email, password, + userDoc: "document here" }); + User.findOne({ email }, (err, existingUser) => { if (err) { return next(err); } if (existingUser) { @@ -94,7 +99,8 @@ export let getLogin = (req: Request, res: Response) => { return res.redirect("/home"); } res.render("login.pug", { - title: "Log In" + title: "Log In", + user: req.user }); }; diff --git a/src/server/authentication/models/User.ts b/src/server/authentication/models/User.ts index bc838bb47..30fcecd81 100644 --- a/src/server/authentication/models/User.ts +++ b/src/server/authentication/models/User.ts @@ -1,6 +1,5 @@ //@ts-ignore import * as bcrypt from "bcrypt-nodejs"; -import * as crypto from "crypto"; //@ts-ignore import * as mongoose from "mongoose"; var url = 'mongodb://localhost:27017/Dash' |
