forked from linnovate/mean
-
Notifications
You must be signed in to change notification settings - Fork 0
/
routes.js
executable file
·91 lines (74 loc) · 3.3 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
module.exports = function(app, passport, auth) {
//User Routes
var users = require('../app/controllers/users');
app.get('/signin', users.signin);
app.get('/signup', users.signup);
app.get('/cadastro-beneficiario', users.cadastroBeneficiario);
app.get('/signout', users.signout);
app.get('/users/me', users.me);
//Setting up the users api
app.post('/users', users.create);
app.post('/cadastroBeneficiario/create', users.create);
//Setting the local strategy route
app.post('/users/session', passport.authenticate('local', {
failureRedirect: '/signin',
failureFlash: true
}), users.session);
//Setting the facebook oauth routes
app.get('/auth/facebook', passport.authenticate('facebook', {
scope: ['email', 'user_about_me'],
failureRedirect: '/signin'
}), users.signin);
app.get('/auth/facebook/callback', passport.authenticate('facebook', {
failureRedirect: '/signin'
}), users.authCallback);
//Setting the github oauth routes
app.get('/auth/github', passport.authenticate('github', {
failureRedirect: '/signin'
}), users.signin);
app.get('/auth/github/callback', passport.authenticate('github', {
failureRedirect: '/signin'
}), users.authCallback);
//Setting the twitter oauth routes
app.get('/auth/twitter', passport.authenticate('twitter', {
failureRedirect: '/signin'
}), users.signin);
app.get('/auth/twitter/callback', passport.authenticate('twitter', {
failureRedirect: '/signin'
}), users.authCallback);
//Setting the google oauth routes
app.get('/auth/google', passport.authenticate('google', {
failureRedirect: '/signin',
scope: [
'https://www.googleapis.com/auth/userinfo.profile',
'https://www.googleapis.com/auth/userinfo.email'
]
}), users.signin);
app.get('/auth/google/callback', passport.authenticate('google', {
failureRedirect: '/signin'
}), users.authCallback);
//Finish with setting up the userId param
app.param('userId', users.user);
//Article Routes
var articles = require('../app/controllers/articles');
app.get('/articles', articles.all);
app.post('/articles', auth.requiresLogin, articles.create);
app.get('/articles/:articleId', articles.show);
app.put('/articles/:articleId', auth.requiresLogin, auth.article.hasAuthorization, articles.update);
app.del('/articles/:articleId', auth.requiresLogin, auth.article.hasAuthorization, articles.destroy);
//Finish with setting up the articleId param
app.param('articleId', articles.article);
//Eventos Routes
var eventos = require('../app/controllers/eventos');
app.get('/eventos', eventos.all);
app.get('/eventos/cadastro', eventos.cadastro);
app.post('/eventos', auth.requiresLogin, eventos.create);
//app.get('/eventos/:articleId', eventos.show);
//app.put('/eventos/:articleId', auth.requiresLogin, auth.article.hasAuthorization, eventos.update);
//app.del('/eventos/:articleId', auth.requiresLogin, auth.article.hasAuthorization, eventos.destroy);
//Finish with setting up the articleId param
//app.param('articleId', eventos.article);
//Home route
var index = require('../app/controllers/index');
app.get('/', index.render);
};