forked from dannegm/Mejorando.la-Chat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroutes.js
49 lines (43 loc) · 1.43 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
//Importar de Controllers Admin y Website
var website = require('./controllers/website'),
admin = require('./controllers/admin');
//Comprobacion de administrador
function is_admin(req, res, next) {
if(req.user && req.user.admin) {
next();
} else {
res.redirect('/');
}
}
module.exports = function (app, passport) {
/*
* Urls del Website
*/
app.get('/', website.index);
app.post('/feedback', website.feedback);
app.get('/salir', website.salir);
/*
* Urls de administracion
*/
app.get('/admin', is_admin, admin.index);
app.get('/admin/feedback', is_admin, admin.feedback);
app.get('/admin/feedback/:date', is_admin, admin.feedback_single);
app.get('/admin/users', is_admin, admin.users);
app.get('/admin/socketReport', is_admin, admin.socketReport);
app.post('/admin/update', is_admin, admin.update);
/*
* Urls de autenticacion
*/
// Auth Twitter
app.get('/auth/twitter', passport.authenticate('twitter'));
app.get('/auth/twitter/callback',
passport.authenticate('twitter', { successRedirect: '/',
failureRedirect: '/' }));
// Auth Facebook
app.get('/auth/facebook', passport.authenticate('facebook'));
app.get('/auth/facebook/callback',
passport.authenticate('facebook', { successRedirect: '/',
failureRedirect: '/' }));
//Todo lo demas 404 NOT FOUND
app.all('*', website.notFound);
};