diff options
Diffstat (limited to 'src/server/index.ts')
-rw-r--r-- | src/server/index.ts | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/src/server/index.ts b/src/server/index.ts index 3b8659d0e..3f7f73b39 100644 --- a/src/server/index.ts +++ b/src/server/index.ts @@ -69,17 +69,32 @@ app.use((req, res, next) => { }); app.get("/signup", getSignup); +// app.post('/signup', passport.authenticate('local-signup', { +// successRedirect : '/profile', // redirect to the secure profile section +// failureRedirect : '/signup', // redirect back to the signup page if there is an error +// failureFlash : true // allow flash messages +// })); app.post("/signup", postSignup); app.get("/login", getLogin); app.post("/login", postLogin); + + let FieldStore: ObservableMap<FIELD_ID, Field> = new ObservableMap(); // define a route handler for the default home page -app.get("/", (req, res) => { +app.get("/home", (req, res) => { + if (!req.user) { + res.redirect("/login"); + return; + } res.sendFile(path.join(__dirname, '../../deploy/index.html')); }); +app.get("/", (req, res) => { + res.redirect("/login"); +}); + app.get("/hello", (req, res) => { res.send("<p>Hello</p>"); }) @@ -89,6 +104,24 @@ app.get("/delete", (req, res) => { res.redirect("/"); }); +app.get('/logout', function(req, res){ + req.logout(); + const sess = req.session; + if (sess) { + sess.destroy((err) => { + if (err) { + console.log("ERRRRRRROOOOOOOOORRRRRRRR IN LOG OUT"); + console.log(err); + return; + } + // return res.send({ authenticated: req.isAuthenticated() }); + }); + res.redirect('/login'); + } else { + res.redirect('/'); + } +}); + app.use(wdm(compiler, { publicPath: config.output.publicPath })) |