-
Notifications
You must be signed in to change notification settings - Fork 27
/
routes.js
59 lines (40 loc) · 1.75 KB
/
routes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/** routes.js
*/
var passport = require('passport');
var start = require('./routes/index');
var notes = require('./routes/notes');
var events = require('./routes/events');
function ensureAuthenticated(req, res, next) {
if (req.isAuthenticated()) { return next(); }
res.redirect('/login');
}
module.exports = function(app) {
app.get('/', start.index);
app.get('/register', start.getRegister);
app.post('/register', start.postRegister);
app.get('/about', start.about);
app.get('/login', start.login);
app.post('/login', passport.authenticate('local',
{
successRedirect: '/account',
failureRedirect: '/login'
})
);
app.get('/account', ensureAuthenticated, start.getAccount);
app.get('/logout', start.logout);
app.get('/reviewNotes', ensureAuthenticated, notes.reviewNotes);
app.get('/newNote', ensureAuthenticated, notes.getNewNote);
app.post('/newNote', ensureAuthenticated, notes.postNewNote);
app.get('/myNotes', ensureAuthenticated, notes.getMyNotes);
app.get('/myEventNotes', ensureAuthenticated, notes.getMyEventNotes);
app.get('/eventNotes', ensureAuthenticated, notes.getEventNotes);
app.post('/eventNotes', ensureAuthenticated, notes.postEventNotes);
app.get('/userNotes', ensureAuthenticated, notes.getUserNotes);
app.post('/userNotes', ensureAuthenticated, notes.postUserNotes);
app.get('/newEvent', ensureAuthenticated, events.getNewEvent);
app.post('/newEvent', ensureAuthenticated, events.postNewEvent);
app.get('/setEvent', ensureAuthenticated, events.getSetEvent);
app.get('/setEvent/:id', ensureAuthenticated, events.setEventID);
app.get('/sortEvents/:operation', ensureAuthenticated, events.setEventSort);
app.get('/clearEvent', ensureAuthenticated, events.clearEvent);
}